Tuesday, December 28, 2010

Simple Collision Avoidance

Recently I'm been thinking about how could I implement collision avoidance in my game.

Well, after googling, I found a very useful blog and he'd teach about how to implement collision avoidance.

Here's the link:

Basically his idea is simple, when the object is near to obstacle, the obstacle will act like a magnet pushing you away from itself. After that, it will try to pull you back. With this implementation the effect of movement is quite smooth but sometimes it will still stuck due to the path between two obstacles is not big enough for the object to pass by.

Since it is not a path-finding based implementation, so it might not give you the shortest path.
If you're looking for A* implementation you might need to search for other resources which uses A* to implement collision avoidance.

Here are some screenshots:
*The object trying to move to the right

*It will slide down and continue its path

*Until it reaches the destination

Video demo:



You can get the program demo here:
PS: It's in XNA 4.0 so you need to install XNA redistributable 4.0 before you can run it

No comments:

Post a Comment