I want to be able to have the player spawn an object, which has a camera as a component. So the player can go around the level placing these cameras.
Now… how do I get the player to switch to that placed cameras view? I want the user to press a key and the view jumps to that item camera view. and then press it again it and it goes back to the original first person view.
I would use possession, i’ve done something similar although it is the reverse (where you are a camera, and can possess a character by clicking on them, then go back to the camera by pressing a button)
1: I created and implemented an interface for the camera and possessable actor, it is a blank interface and only serves to deliver a signal to the character that they should be possessed:
2: I trace the location i clicked on, and using that trace I send the possession signal to an object that was clicked on.
3: In the object this is the code i use to possess it (above) and the code i use to go back to my camera (below)
The reason I use an interface rather than just a regular possess node on it’s own is because it was easier for me that way if I wanted to possess a specific actor of which multiple instances might possibly exist, so i specified which one by clicking on them. It was also because converting the hit actor to a pawn reference to pass through to the possess node was convoluted as balls.
There is only ever going to be one camera instance for me, so i just used get all actors of the camera’s class to return to it.
Instead of using an interface, I would recommend that you add all your cameras into an array as as they are created and use the possession node in combination with the array to determine which camera to possess.