Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Camera Motion

Sign in to follow this  


Camera Motion

First of all, thanks to those of you who responded to my Poll in the last update. If you haven't yet, please respond if you get a chance.

Man, changing the camera has such a huge impact on so many things. One thing that I'd been meaning to fix for a long time was the camera sometimes clipping into the world. This is caused when part of the world geometry intersects the near clip plane, causing a distracting artifact right in front of the viewer, including showing off the wonders of back face culling.

This was something that would happen rarely in the past, but happened much more frequently as I allowed the camera zoom-in feature to move down & behind the character more. This prompted me to fix it sooner rather than later.

So, last night I implemented the first version of a non-penetration camera. I'm sure it will change over time, but so far, I like it pretty well.

I took a two-step approach. The first step was to make it so the camera never penetrated anything, but didn't worry about being smooth or feeling nice. I got this done pretty quickly, but it was about as disorienting as I feared, with the camera snapping around as you turned the character, and objects behind the character that might get clipped forced the camera to snap its position to somewhere safe.

Clearly, to make it more smooth, I'd need to do the second version, which works like so :

1) Save the last camera position. Handle the first frame special case nicely.

2) Create the new desired camera position, ignoring all clipping issues.

3) Simulate a sphere starting 20 meters above the new desired camera position, moving straight down.

4) Make the sphere radius big enough to encompass the viewpoint and near clip plane in world units.

5) Drop it straight down to the desired camera level, stopping at the first collision, if any.

6) Figure out the delta between where the sphere ended up and where it was trying to go.

7) Add a small percentage of this delta ( like 3.5% to the old camera position height ) to the last camera height.

8) Use this moving average as the new camera height.

This system does not actually totally prevent clipping if you turn very fast into a narrow, tall object, but it is quite rare and only lasts for a few frames. There is a clear tradeoff between accuracy and smoothness. For instance, making the sphere radius bigger than needed will detect potential colliders earlier, letting the adjustment be more gradual and less distracting to the player, but it will also have the effect of making the camera move around obstacles that are really not in danger of getting clipped by the camera due to distance.

An alternative involves simulating the camera from where it is, rather than dropping it from above. This could include lateral motion as well.

Another method would start the sphere at the player's back, and move backwards towards the desired camera spot until it hit something. This would allow the camera to zoom into the player instead of climbing over an obstacle.

But, I do like the current system, as moving the camera up & down is what the current zoom system does, so it should feel
quite natural to players.

Something I may add today is the option to keep the player in view. The camera would move up and/or toward the player so that he remained in view. This mode would most likey move the camera target point as well.

Here are the before & after pictures. This is somewhat of an extreme case, as we don't expect to have very tall walls like this that often.

On another note, I cleaned up some of the property text files for the levels, so each level can specify skybox paramters,
and whether post-processing is enabled for that level.
Sign in to follow this  


Recommended Comments

Very good idea.
In WoW, they made the camera, that moves from the head backward to min( dist, collision ) and it is ok, until you turn fast and meet some close collider - then camera jumps at light speed just infront of that collider.
Sometimes it is frustrating, because you lose your sense of where you are.
That's why your method seems better to me.

Very nice journal, reading it with interest! :)

Share this comment

Link to comment
I considered that as well. I really don't want that level of player distraction if possible. Since the player already has the ability to move the camera up & down, I feel that this is the most natural way to go for our game.

Thx for the feedback.

Share this comment

Link to comment
And you really should see WoW controls, (except that camera jumping), they are very smooth and cool, and definitely can add to the feeling of one's character.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!