Archived

This topic is now archived and is closed to further replies.

Collision detection.

This topic is 5581 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK im making an overhead car game a bit like GTA 1. Say you have car which is rotated with left and right and you have a seperate accelerate function, so teh rectangle i am using to represent the car can be at any angle around a central point (which represents the car, with a forward and sideways velocity, and an angle of turning). The game world is built using tiles, some of which are freely travelable road, and some are immoveable buildings. When the car hits a building (calculated by taking the four corners of the cars rectangle and checking to see if they fall in any building, then moving the car back into the road area next to the building it hit at the angle it was going (not perfect but what is)) what should happen? should the car bounce off at a funny angle? should all velocity that pushes into the wall be destroyed? and is my method of putting the car back on the road a total mess? I plan to do it before drawing to the screen but it still ignores physics a bit and will need a high framerate to stop weird shit going on. the good thing is i know what tile each point of the car is on so i can just check that really quickly. comments please it would be nice if when the car hits the wall at a funny angle it can go spinning off but i dont know how to do that. how to i apply a force which hits the front of the car on the side when the car is represented as a point? do i need to add a rotational speed thing too and do some force x distance calcs? [edited by - hungry joe on September 1, 2002 11:02:43 PM]

Share this post


Link to post
Share on other sites
To do the spin, you could check the distance of the collision from the middle points of the car sides. For example, for the side, the middle point would be around the opening part of the driver''s side door. And if they collided on that side, and the wall or building mostly hit toward the front and didn''t pass the midpoint and hit the back part, the car would spin clockwise (and probably smash into the other side of the building )

I''m not so sure about the rotating rectangle part. I''m not an expert, but you may be ahead using a different method.

Share this post


Link to post
Share on other sites