How create a empty Actor?

I’m trying to dynamically create an Actor to be my camera’s relative “using a c# script” but I don’t know if this is possible, my intuition was that the code below would work.

// start
Actor cameraCenter = new Actor();
cameraCenter.Parent = Actor;
cameraCenter.LocalPosition = new Vector3(0, 0.5f, 0);

Actor cameraPivot = new Actor();
cameraPivot .Parent = cameraCenter;
cameraPivot .LocalPosition = new Vector3(0, 0, -3f);
cameraPivot.LocalOrientation = Quaternion.Identity;

MyCamera.Parent = cameraPivot;
MyCamera.LocalPosition = Vector3.Zero;


// update
cameraCenter.Center.Orientation = Quaternion(<mouseY>,  <mouseX>, 0);
MyCamera.LookAt(<lookat>)

Use new EmptyActor() type to create an empty actor.

2 Likes

Thanks my hero! :blush:

How do you get the new actor to show in the scene hierarchy? It says its created it and I named it but I don’t see it at all in the scene hierarchy view and the script I added onto it (a singleton) returns null still.

Actor needs a parent on a scene to be there. You can also use Level.SpawnActor(myActor) to add it into the game automatically.

1 Like