|
-
Flash car collisions/hitTest (as2)
Well, ive been using flash for a long time but i have to say im no pro at coding. I know some stuff, but not enough for what im trying to do.
Basically, im making a little car minigame of a car in a city. This is my engine on the car:
onClipEvent(load)
{
speed =0 ;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
speed += 0.4;
}
if (Key.isDown(Key.DOWN)) {
speed -= 0.1;
}
if (Key.isDown(Key.SPACE)) {
speed /= 1.15;;
}
if (Math.abs(speed)>20) {
speed *= .7;
}
if (Key.isDown(Key.LEFT)) {
if (speed < 0.5) {
_rotation -= speed;
} else {
_rotation -= 5;
}
}
if (Key.isDown(Key.RIGHT)) {
if (speed < 0.5) {
_rotation += speed;
} else {
_rotation += 5;
}
}
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.wall.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
Im fine with all of it but the collisions, as the car will only bounce when the registration point of the car collides with 'wall', so it looks all funny and that and the car goes into any thing collable half way then bounces back, and occasionally gets stuck in the wall. Reall annoying. Ive tried fixing it but whenever i remove the hittest parts the car wont even move or turn.
PLease help me so the wall collides with the car (27.7 x 13) and not the registration, i would be so gratefull.
Note i need a strong engine which works with curves aswell, and requirs me just putting the code into the car, but if i have to put it into the walls/frame i suppose its okay, but theres no way im going through every single building and that.
Also, it would be cool if:
-You could give me an engine where when reversing the steering is reversed (like irl)
-The car doesnt bounce backwards when driving at a wall at an angle, but slides against it (like irl)
Thanks. (btw, ive tried sites like emanuale fernando and that but they never work).
-SM
-
Hey guys, i really need this so if i got a reply id be over the moon - i dont really appreciate having the next few threads get replys.
-
please stop making me have to double post an bump, please
-
guys, im getting really hacked off now.
-
COME ON, this site sucks if you can wait this long without a reply. its been a whole week.
-
SERIOUSLY GUYS! why the hell is this one of the first forums on google if you cant even get a reply after a week and 100 views?
-
Flash/Flex Developer
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
That doesnt help since its AS3 and not for car movement.
-
Why do i even bother? this site is crap and has been no help whatsoever. Good bye.
-
Flash/Flex Developer
And that is why no one answered your question.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|