Jump to content
  • Advertisement
Sign in to follow this  
edwinnie

heightmap collision with bouncy camera

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

hi! I have a third person camera centered on a moving object, where the object is on a rough terrain using a heightmap. My camera is parented to the object, so when the object detects a slight change in height, my camera vibrates or bounces, and so the rendering looks jerky. I wonder how do the games do such smooth character motions on rough terrain... thx! Edwinz

Share this post


Link to post
Share on other sites
Advertisement
If your camera is naive to the underlying surface of the terrain, then this would be hard to do. It would be pretty trivial to just base the camera position over some _interpolated_ terrain height though.

Share this post


Link to post
Share on other sites
Another idea, in case your camera is naive to the terrain, is to round the heigh up. For example, if your height goes from 1000 to 2000, I'd have the camera positioned at (int(playerY/10)*10) or something like that.

Share this post


Link to post
Share on other sites
so the idea is to have the camera positions interpolated at runtime and seeing a smooth delay to the actual camera destination?

thx!
Edwin

Share this post


Link to post
Share on other sites
You can dampen the camera motion. One way is to do something like so :



float delta = camera.desired_height - camera.height;

camera.height += delta * 0.1f;




This way, it only moves 10% of the way to the new height each frame. You can further scale delta by the frame time to get it frame-rate independent if you prefer.

Share this post


Link to post
Share on other sites
SimmerD, I've seen (and tried) suggestions like that before but they really don't work all that well. Assuming constant frame rate (as you mention) and assuming the target and camera both start at 0.0, consider the target moving +1.0 per frame...

Target 0.0. Camera 0.0
Target 1.0, Camera 0.1
Target 2.0, Camera 0.229
Target 3.0, Camera 0.5061
...

The camera lags so far behind as to be unusable. Even when the target stops, it also takes ages to get anywhere near where it should be, and actually won't ever reach the target (just get very close to it).

In fact, as a heightfield, you may have reason to believe there wouldn't be drastic or continual changes in one direction in which case it might not look terrible. As a general solution (eg. position instead of just height) it really wouldn't work.

Much better would be to record a series of recent heights/positions and take an average of them. The current game I'm working on takes a biased average of the last five positions, so is very smooth yet stays reasonably close to the target, and reaches it when the target is non-moving.

Share this post


Link to post
Share on other sites
I wrote up a few lag functions here:

http://www.devmaster.net/wiki/Third-person_camera


The trick you is that the % is between the curret position and the desired position and not between the start position and the end one! Also don't assume anything about frame rate, just scale the diffrence by the time delta.

Share this post


Link to post
Share on other sites
Thanks :) I never could spell even with a spell checker, the words all look right when I read them :P

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!