Camera Judder

Blitz3D Forums/Blitz3D Beginners Area/Camera Judder

siread(Posted 2007) [#1]
I'm trying to create a 3rd person camera that zooms according to 2 objects. Basically the camera will focus the one player, but when another player goes out of view to zoom out to show more of the view. I tried a simple thing such as:

If Not EntityInView(player2, camera)
    zoom = zoom - 0.05
else
    zoom = zoom + 0.05
EndIf

If zoom < 0.2 then zoom = 0.2
If zoom > 1 then zoom = 1


The trouble with this is when player2 returns to the view it zooms in which puts player2 out of view, then zooms out again and so on. This makes the zoom jerk in and out continuously while the player2 is at the edge of the view.

What's the best way to achieve the effect I'm looking for?


chwaga(Posted 2007) [#2]
what your problem is, is that you're saying that no matter what, when player2 is in view of the camera, zoom in. What you need, is a elseif statement, saying that
If Not EntityInView(player2, camera)
    zoom = zoom - 0.05
ElseIf zoom > n (n represents your minimum zoom)
    zoom = zoom + 0.05
EndIf

If zoom < 0.2 then zoom = 0.2
If zoom > 1 then zoom = 1


that should work, but also you must add conditions to the elseif depending on what the game is, how you want the camera to act, etc.