# Making a racing game... Need help doing some collision stuff

**URL:** https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343
**Category:** Uncategorized
**Created:** [May 26, 2004, 2:02am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343 "2004-05-26T02:02:11Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![patricktheking](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@patricktheking](https://forum.kirupa.com/u/patricktheking)
#### Post date: [May 26, 2004, 2:02am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/1 "2004-05-26T02:02:11Z")

</div>

K im making a racing game and I want it so as you race over the finish line it goes to the next frame which will have the next track… How do i do that…

I make the finish line a movie clip… then what?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 2:14am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/2 "2004-05-26T02:14:28Z")

</div>

It’s called a hitTest, there is a tutorial here on kirupa that should help you out. I’ll see if I can find it for you.

[http://www.kirupa.com/developer/actionscript/hittest.htm](http://www.kirupa.com/developer/actionscript/hittest.htm)  
There you go 🙂  
Just change the code where it changes the text to be nextFrame(); and change the movieclips to the instance names of your movieclips (car and finishline)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 2:16am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/3 "2004-05-26T02:16:37Z")

</div>

thanks so mUCH…!!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 2:54am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/4 "2004-05-26T02:54:35Z")

</div>

onClipEvent (enterFrame) {  
if (\_root.circle, hitTest(\_root.block)) {  
\_root.text = “Collision Detected”;  
} else {  
\_root.text = “No Collision”;  
}  
}

thats what it gives me on that turtorial… so do i change it 2…

onClipEvent (enterFrame) {  
if (\_root.car, hitTest(\_root.finishline)) {  
\_root.nextframe();

??

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 3:14am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/5 "2004-05-26T03:14:40Z")

</div>

Thats all i can think of and it isnt working…

onClipEvent (enterFrame) {  
if (\_root.car, hitTest(\_root.finishline)) {  
actions  
}  
nextFrame();  
} else {  
play();

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 3:44am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/6 "2004-05-26T03:44:22Z")

</div>

```auto

onClipEvent (enterFrame) {
if (_root.car, hitTest(_root.finishline)) {
_root.nextframe();
} else {
stop();
}

```

it should look something like that.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 7:39pm UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/7 "2004-05-26T19:39:40Z")

</div>

na it doenst work

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2004, 7:52pm UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/8 "2004-05-26T19:52:18Z")

</div>

K… I attached wat you said 2 and now my car wont move…

onClipEvent (enterFrame) {  
if (\_root.car, hitTest(\_root.finishline)) {  
\_root.nextframe();  
} else {  
play();  
onClipEvent (enterFrame) {  
//This code will advance the car forward.  
if (Key.isDown(Key.UP)) {  
speed += 1;  
}  
// This will make the car go backwards  
if (Key.isDown(Key.DOWN)) {  
speed -= 1;  
}  
//The car will start to slow down after the speed of 25  
if (Math.abs(speed)\>25) {  
speed \*= .6;  
}  
// This will change the angle of the car  
if (Key.isDown(Key.LEFT)) {  
\_rotation -= 15;  
}  
if (Key.isDown(Key.RIGHT)) {  
\_rotation += 15;  
}  
// This will make the car move  
speed _= .98;  
x = Math.sin(\_rotation_(Math.PI/180))_speed;  
y = Math.cos(\_rotation_(Math.PI/180))_speed_-1;  
if (!\_root.move.hitTest(\_x+x, \_y+y, true)) {  
\_x += x;  
\_y += y;  
} else {  
speed \*= -.6;  
}

that is wat the movieclip car has attached 2 it and now it wont move as i added that hittest stuuff…

these errors keep poping up as i test teh movie

cene=Scene 1, Layer=Layer 2, Frame=1: Line 36: Syntax error.

Scene=Scene 1, Layer=Layer 2, Frame=1: Line 1: Statement block must be terminated by '}'  
onClipEvent (enterFrame) {

Scene=Scene 1, Layer=Layer 2, Frame=1: Line 36: Syntax error.

its really getting anooying… plz help…

note \*I put the movieclip finishline on a seperate layer but that wont matter i dun think as long as it has it’s instance name

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 4:44am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/9 "2004-05-27T04:44:46Z")

</div>

if(\_root.car.hitTest(\_root.finishline))

😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 5:03pm UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/10 "2004-05-27T17:03:36Z")

</div>

lol it dont work

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 5:04pm UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/11 "2004-05-27T17:04:20Z")

</div>

onClipEvent (enterFrame) {  
if(\_root.car.hitTest(\_root.finishline))  
\_root.nextframe();  
} else {  
play();

still dun work…lol

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 5:38pm UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/12 "2004-05-27T17:38:48Z")

</div>

all little tut:

[size=3]That goes up, must come down.  
[size=2]  
the same is for font=Courier New,{},[],""  
[/font][/size][/size]  
end tut  
[size=3][size=2][font=Courier New]  
[/font][/size][/size]now take a look at you code

```auto

 onClipEvent [color=Sienna]([/color]enterFrame[color=Sienna])[/color] [color=Blue]{[/color]
  if[color=DarkOrange]([/color]_root.car.hitTest[color=DarkOrchid]([/color]_root.finishline[color=DarkOrchid])[/color][color=DarkOrange])[u]**[color=MediumTurquoise]{[/color]**[/u][/color]
  _root.nextframe[color=Lime]()[/color];
 [color=MediumTurquoise] }[/color] else [color=Red]{[/color]
  play[color=Green]()[/color];
 [u]**[color=Red]}[/color]**
 **[color=Blue]}[/color]**[/u] 
 

```

bold and underline are things you missed.

🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 5:50pm UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/13 "2004-05-27T17:50:12Z")

</div>

k lemme try it

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 5:53pm UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/14 "2004-05-27T17:53:30Z")

</div>

It Works… It Works … Thankyee It Works

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 28, 2004, 8:27am UTC](https://forum.kirupa.com/t/making-a-racing-game-need-help-doing-some-collision-stuff/111343/15 "2004-05-28T08:27:03Z")

</div>

they say when a you get a peice of code to work an angel gets its wings
