Skip to main content
GameDev.net gamedev.net
🔒 Locked

Basic FPS Physics Part 2

Started by dave Jul 12, 2010 at 7:10 AM 1 replies 1.7k views
Original Post
dave
dave
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,
Buckeye
Buckeye
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?).
Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly. You don't forget how to play when you grow old; you grow old when you forget how to play.
dblack
dblack
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.