Page 1 of 1

[C#] How rotate camera around an entity?

Posted: Wed Nov 20, 2019 1:33 pm
by dan.b.s
Hi,

What is the best way to rotate a camera around an entity programmatically?

I rotate my camera by adding an empty entity (pivot) in the code, then set the camera as a child, and rotate the empty entity.
I'm away from my pc, but it would be like this:

Code: Select all

public class movement : EntityComponent { Entity camera; Entity pivot; //OnGameStart ... camera = Entity.Find("mainCamera"); pivot = Entity.Spaw...; pivot.Position = Entity.Position; camera.Parent = pivot; ... //OnUpdate //Rotate pivot... }
Thanks!

Re: [C#] How rotate camera around an entity?

Posted: Wed Nov 27, 2019 9:04 am
by mknmknmknjk
adjust camera relative transform by mouse x,mouse y. relative position and relative rotation.