I am attempting to write an orbit control (basically, get the camera in my game to behave the same way the godot viewport does). I am doing this to familiarize myself with the godot transforms.
So far I have the positioning of my camera working. However, when I try to point it at the center of orbit (0,0,0), the LookingAt function fails to work. Printing out (The C# debugger isn't working *cry*) the values show no change occurs as a result of this function. This is despite the fact that the camera is moved around. I tried various values for the up-axis, no change witnessed.
Here are the pertinent functions from my Camera node's script:
private Vector2 rotateStart;
private Vector2 rotateEnd;
private Spherical spherical = new Spherical();
private Vector3 target = new Vector3();
public void HandleRotation(float delta)
//Current cursor location
rotateEnd = GetViewport().GetMousePosition();
//Get change since last time
Vector2 RotateDelta = rotateEnd - rotateStart;
//Get the transform...
var transform = GetGlobalTransform();
//Set the spherical to the current location
//Get viewport size
var viewportSize = GetViewport().GetVisibleRect().Size;
//Calculate changes to equatorial and vertical rotations.
spherical.theta += 2 * (float)Math.PI * RotateDelta.x / viewportSize.x;
spherical.phi += 2 * (float)Math.PI * RotateDelta.y / viewportSize.y;
//Vector to store the final transform
var final_transform = new Vector3();
//Copy spherical cordinates to position vector.
//Apply position change to object transform.
transform.Translated(final_transform - transform.origin);
//Point at origin (point of orbit)
transform.LookingAt(target, new Vector3(0, 1, 0));
//Print transform, outputs not chang during tests.
//LookAt(target, new Vector3(0, 1, 0))
//Apply the transform
//Save last position.
rotateStart = rotateEnd;
public override void _Process(float delta)
// Called every frame. Delta is time since last frame.
// Update game logic here.
//Todo, move this to input event
rotateStart = GetViewport().GetMousePosition();