Jump to content
  • Advertisement
Sign in to follow this  
G-Man9566

Staying on top of things

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

I want to share with you all how I am implementing "gravity" (walking on surfaces, therefore not being able to "fly" through the floors etc. with the camera) in my First Person implementaion and want to know your opinion and if you have any better ideas than this one, or any other idea for that matter. I got the idea from p.479, Chapter 8 of "3D Game Engine Design" by David H. Eberly, 2007. The basic idea is that you project a ray downwards from you camera position ( -y in world coordinates ) and do a pick with the projected ray. The closest object that is picked is obviously/hopefully the object that your Player wants to stand on (floor/terrain/stairs etc.). You then set your camera's y-position to the intersected point's y position plus a certain offset. And this implementation works fine and well for most cases. Where I get a problem is walking up stairs. When I walk up a staircase the camera would "jump" from the current step to the next, therefore the whole motion is very jagged. Whereas in the real world one's motion is much smoother up stairs. What do you think?

Share this post


Link to post
Share on other sites
Advertisement
The answer lies here in using an additional mesh for the stair as collision-mesh. Instead of the visual mesh which you render, you let the camera raytrace with the collision mesh instead.

This collision mesh wouldn't be exactly the same as the visual one, but more simple. It will look more piramidic, think of right-angled triangle if you look from the side.

Another option would be placing some kind of animator on your current camera height that allows a more smooth transition between his current value and his next value over time.

Share this post


Link to post
Share on other sites
One thing you could do is to smooth the motion.

This can be done by detecting when the motion in the y-direction is larger than some threshold. Upon detection, rather than jumping directly to the new y-value, you can interpolate between the old value and the new one over a number of frames.

This way, you should get a smooth transition.

Share this post


Link to post
Share on other sites
Hey, both those solutions sounds like good ideas.

I did actually consider using "collision mesh" for staircases and other places where the camera motion could be jagged, but what I did not like about the idea was that it put more work on the 3D Artist to model the "collision mesh" and it would be pretty boring to model.

I do like the idea of applying a type of "filter" on the motion of the camera, therefore smoothing out jagged trasitions. I will definetely have a look at that one.

Any more ideas? Are there any other way of "staying on top of things" besides projecting a ray and offsetting your position?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!