Control Cameras With a Scene Graph Camera Component (Experimental)

Hello, I recently found this video on X by user krisp. Brilliant. This could open lots of new and exciting driving game possibilities.

I’ve been trying to get something like this working. Not having lots of luck. I can get it to switch to “a” camera but it is stationary and does not follow the player.

I am a novice Verse user, Epic Developer Assistant is helping!

Any tips or links to creating something like this?

Appreciated!

Hey, how’s it going? I assume you’ve managed to create the entity and add it to the player’s CameraDirector. Now you need to set the entity’s origin and its position with an offset. Get the Entity from FortCharacter[].GetEntity[], then set it as the origin of your camera’s transform using CameraEntity.SetOrigin, and adjust its position within the entity using SetLocalTransform. The position within the SceneGraph hierarchy is very important; it is crucial for creating custom inventories, for example.

if:
   FortChar := Player.GetFortCharacter[]
   CharacterEntity := FortChar.GetEntity[]
then:
   CameraEntity := entity{}
   CharacterEntity.AddEntities(array{CameraEntity})

   CameraEntity.SetOrigin(entity_origin{Entity := CharacterEntity})
                   CameraEntity.SetLocalTransform((/Verse.org/SpatialMath:)transform{
   Translation := LocalCameraOffset
   })

  MyCamera := perspective_camera_component{Entity := CameraEntity,   FieldOfViewDegrees := FieldOfViewDegrees}
  CameraEntity.AddComponents(array{MyCamera})

   if(Director := Player.GetComponent[camera_director_component], Director.AddCamera[MyCamera, CameraPriority]):

Speaking of swapping cameras, when you add a camera, you can store it in a variable of type cancelable so you can remove it later. You can either add them all with their priorities and then remove them using Cancel(). Here is the link to the documentation you need.

Camera Director and Transitions in Unreal Editor for Fortnite | Fortnite Documentation | Epic Developer Community

Just to mention, I couldn’t find a way to move the camera along the vertical axis without it getting really glitchy. The camera manages the horizontal movement on its own.

You sir are brilliant! It works now! Thank you for the help.

Cheers!