How to output the coordinates of a virtual camera from UE?


I’m a beginner.

Can anyone helps me to output the coordinates of a virtual camera( or other objects) from UE?

I want to use this coordinates information to move a real camera or an object.

Thank you so much.

Hey there @carrcc_1! Welcome to the community! So with any actor in Unreal Engine, you can get their world location with Get Actor Location nodes:

1 Like

Some Actor drives the camera. This is typically a Floating Spectator Pawn or a Character.
That Actor could have behavior inside Tick() that reads the camera position and orientation (from its CameraComponent) and outputs it to wherever you need it to.

If you need to output it to some kind of network device, you will want to create a socket and connect it – this can be done in C++ similar to how you’d do it in any other program. Just don’t block the main thread while reading/writing the socket, or waiting for a connection!

If you just need the movement as a track for later motion matching, you can write to a file on disk. Open the file in BeginPlay() and close it in EndPlay() or Destroy().

One thing to beware of: Unreal will create multiple instances of your class, at least one is the “class default object” in addition to the real instance; with networking or level travel, more copies may be created. You can tell that your controlled Actor (Pawn) is “the real one” by getting the controller from it and making sure that it’s valid and a PlayerController subclass.

1 Like

Thank you. Let me try it.

Thank you. Let me try it. :slight_smile: