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

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?

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
There you go :slight_smile:
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)

thanks so mUCH…!!!

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();

??

Thats all i can think of and it isnt working…

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


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

it should look something like that.

na it doenst work

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

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

:wink:

lol it dont work

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

still dun work…lol

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


 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.

:slight_smile:

k lemme try it

It Works… It Works … Thankyee It Works

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