-
Car movement (as seen in parking games)
Hi all..
I noticed there are a few parking games around, such as:
http://www.mousebreaker.com/games/parking3/play.php
Zurich Insurance had one as a viral/promotional gimmick which worked in a similar way - it may, of course, have been done by the same person.
To me the idea of coding a realistic vehicle movement of this type seems very complex.
I guess the "coming to a halt" idea is not dissimilar from menus that glide a little. But it's the direction that's giving me a headache - you turn the wheels from one side to the other (pivoting around the centre of the wheel) and the front of the car moves in that direction..
But it's clearly not that simple! I tried a few tests and really I couldn't work out how the whole shape of the rectangle should stay constant, let alone move in the correct direction as the car turns.. at times it looked like a squashed shape and at best it was skidding out of control sideways instead of turning!
Is there any standard code/algorithm to mimmick movement of a front wheel drive vehicle in this way? Or is it actually simpler than I realise for anyone with a brain for physics!?
All thoughts & snippets appreciated!
drew
-
Senior Member
try attaching this to the mc
it can bounce off boundaries with an instance name land
onClipEvent (load) {
speed = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(87)) {
speed += 1;
}
if (Key.isDown(83)) {
speed -= 1;
}
if (Math.abs(speed)>20) {
speed *= .7;
}
if (Key.isDown(65)) {
_rotation -= 15;
}
if (Key.isDown(68)) {
_rotation += 15;
}
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
-
Hi - well that's a pretty good start since at least the shape won't distort if I stick to using rotation.. but with this we are pivoting about a corner and it's not following the direction of the front of car (specifically determined by the wheels rather than just the direction of the object).
If you look at that game link you'll see they've got the movement spot on.
I really can't get my head around how the object moves in relation to wheel position.
If rotation of wheels is, say 45 degrees then the object doesn't just turn to reflect that, the front follows the wheel rotation while back of the object follows through the position of the front of the object.
-
Parking Games
Car parking games are some of the most popular online games at the moment. They are very engaging and a fun experience that will surely provide you with enough good moods to go out and start practicing the perfect car parking.
Car Parking Games
-
Apparently this web is not existing anymore, but you can find a good set of parking games here:
Parking Games at Gatoconbota.com
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
|