Jump to content
  • Advertisement
Sign in to follow this  
dave

Basic FPS Physics Part 2

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

So, more physics stuff for FPS games!

If i want to intersect the walls and floor with the player how do i do it? Most of this i believe i have worked out. I don't use a physics volume at the moment, i cast 5 rays, forward, backward, left, right and down. When i walk and jump around in open space, on a piece of floor terrain it all works fine. I cast the rays and the downard ray is the only one that intersects and has an intersection point within range. The normal comes back as (0,1,0), i dot this with the velocity for the frame which is straight down for gravity and the normal cancels out the downward movement.

But how do we combine intersections with walls? If i walk forward and hit a wall that has a surface normal of (0,0,-1), and i also have the intersect with the floor, should i combine these normals to give me (0, 0.707, 0.707) and then resolve the velocity using the dot product? I have tried this and it causes the player to drop through the floor slowly (because the gravity direction dotted with the accumulated normal gives a slight downards motion.

Do we run the floor intersection and surroundings intersection in two distinct passes, or can we combine them as described above?

Thanks,

Share this post


Link to post
Share on other sites
Advertisement
You're trying to apply Newtonian physics (sort of) with the physics system you've created, which appears to be sort of an acceleration/velocity/displacement mix.

Quote:
Do we run the floor intersection and surroundings intersection in two distinct passes..?

From what you've described, yes. If it's compatible with your system, maybe better to resolve each of the 5 ray-casts before combining them, in case you want to add other force/acceleration/velocity mixes later (rocket-packs for horizontal movement?).

Share this post


Link to post
Share on other sites
In general, this doesnt sound like a good way to go about doing the physics for an FPS(perhaps, with some modifications for a much simplified AI system). You will get too many things sliping between the rays etc.

I recommend using a character controller based on sweeping a capsule(or box etc) to determine the max amount a player can move. In addition to adjustments to handle penetration, sliding etc.

If you dont want to spend a fair amount of time on building a robust cc then you could use one from a physics SDK etc(eg Havok, Bullet and PhysX come with one).

Alternativly, the first thing to do is write a sweep test(or something equivelant which considers all shapes at once...). Use google or you can check my blog for the begining of a tutorial on writing sweep tests(I havnt gotten to capsule vs polygon etc yet though). http://therealdblack.wordpress.com

Plus there is a tutorial somewhere for doing the whole thing with ellipsoids(perhaps on gamedev.net?).

David

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!