Jump to content
  • Advertisement

Archived

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

KillerJim

Pedestrian collision avoidance (vectors)

This topic is 5274 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

Hi, I`m writing a small game with pedestrians in it, they currently walk around the sidewalk / pavements using waypoints. I have been trying to get collision avoidance coded for about a week but the maths keeps killing me The collision detection routine works by every pedestrian creating a 1/2 meter circle (in 2D space) 2 meters infront of the pedestrian. Every pedestrian tests for a collision between these ''collision circles'' if a collision occurs a vector between the centers of the circles in worked out.. Now what I think I need to do is to rotate this vector by 90 degrees, so instead of the collision pointing towards to other circle it points away. That means the pedestrians will miss each other when rotated towards that new vector.. I can`t get the vector maths correct, it seems to work for pedestrians walking West to East OK, but Pedestrians walking North to South turn wrongly.. I`m think I need to do something with the forward vector but my minds so fried that I think I need some fresh eyes to look at this Can anyone suggest an (easier?) way to do work out how to convert the ''collision vector'' to an ''avoidance vector''? Thanks for any help, its GREATLY appreciated!! James.

Share this post


Link to post
Share on other sites
Advertisement
Use flocking. This is what it''s for.

Give each user a direction vector to start with (towards their current goal), then add in a ''force'' that repels them from other pedestrians, which directly modifies their direction vector. They''ll all just magically avoid each other.

Share this post


Link to post
Share on other sites
Im guessing you have a 90 degree rotation which involves cos(angle) and sin(angle) and one of them is OK but the other needs multiplying by -1.

But that''s just a hunch, of course

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!