heightmap collision with bouncy camera

Started by
7 comments, last by OrenGL 18 years, 6 months ago
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
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.
¿We Create World?
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.
Dubito, Cogito ergo sum.
so the idea is to have the camera positions interpolated at runtime and seeing a smooth delay to the actual camera destination?

thx!
Edwin
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.
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.
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.
Don't shoot! I'm with the science team.....
OrenGL, I think you forgot * dt in the last two functions. Also, you misspelled 'angleDifference'.
Thanks :) I never could spell even with a spell checker, the words all look right when I read them :P
Don't shoot! I'm with the science team.....

This topic is closed to new replies.

Advertisement