Game Development Community

Orbit camera jitter problem & suggested fix

by Aaron Oneal · in Torque Game Engine · 11/06/2005 (6:46 am) · 1 replies

I kept getting a lot of jitter with the orbit camera with the default behavior that calls setOrbitMode() passing it the player object. It seems the dead player is moving slightly and causing the jitter. So instead, I wanted it to just use the fixed transform of the player at the moment of death so that it wouldn't bounce around due to slight variations in the dead player's transform. So, I began looking here.

camera.cc (494) in ConsoleMethod( Camera, setOrbitMode ...

And basically I discovered that the script method assumes you're going to pass an object even though only a transform is required to the C++ method. In this case, I clearly just want the orbit cam to orbit the position and not the object, so I made the following change:

if(Sim::findObject(argv[2],orbitObject) == false)

Becomes:

if(orbitObject && Sim::findObject(argv[2],orbitObject) == false)

This allows you to pass in a null object from script and have it behave the same way as it does in C++ -- orbit the transform instead of the object. Once I did this and tweaked my script to pass null, the jitter problem went away.

I'd like to suggest this small change to the setOrbitMode console method be incorporated into the main codebase if possible to allow the use of this feature of the orbit cam.