Cast to CameraActor issues

I am trying to get a camera working for a RTS game. I am trying to refernce the camera so it can be used in the movement calculation later. I am having trouble getting it to work, as nothing seems to be compatible with the cast to cameraactor node. I have tried replacing the get player pawn with various nodes, but nothing so far has worked. Any ideas?

I hope I understand your problem correctly. Are you talking about a camera component? This should be quite simple:

grafik

Just drag into your bp and you can work with it.

A Camera is not derived from Character, it is an Actor. So casting will not work.

In case you have just a camera placed into the level, this is a different story.

Either access in level blueprint: Select the actor in the level, then open the level BP and add the reference via the Context Menu:

grafik

Or you can access it in your character by using GetActorOfClass:

you could do this in BeginPlay and keep a reference to it.

GetAllActorsOfClass for multiple actors of that type, the above returns only the first one, but if you have one camera only, that should be ok.

1 Like

Thank you for the help; however, the problem is not fully resolved.
The set local offset, which should cause the camera to move, is not causing the camera to move. There is transformation data coming in (x= -5.0), and the camera reference is imputing “CameraActor_0” into the transform node, using the get actor of class node. When I start the project, 2 cameras appear in the layout (in yellow): Player_Camera and CameraActor. I do not know if this is a problem.

I have fixed the issue. I had the variable set to “Camera Actor”. I changed it to “Pawn”. This fixed the compatibility issue. Thank you for the advice, it helped put me on the right track.

1 Like