Jump to content
  • Advertisement

Archived

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

jimywang

Collision detection in FPS game

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

im making a FPS engine using advanced raycast technology.in the game,i have the wall represented as (x1,y1,x2,y2).i can prevent the player from going through the wall by calculate the distance between the player and the wall right in front of him.the question is how can i go this for the game sprite?can someone helpme with it please?thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
not sure I understand. is it a 2D game? 3D? side view? top view? is it a doom clone?

Share this post


Link to post
Share on other sites
If it ''s a doom-like raycast engine, then the world is described as 2d top view grid. I suugest assuming that each sprite is encompased within a circle. In order to check wheter an obect collides with the surroundings:

For each wall, which is represented by a line:
- Find the perpendicular distance from the center of the
sprite''s circle to the line.
- If the distance is less than the circle''s radius, then
collision fails

For each static object other than walls, use a pre-determined approximate bounding circle:
- Check the distance between the center if sprite''s
circle and the object''s one.
- If it is less than the sum of the two radi, then
collision fails

Hope this help.

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!