# Move Camera to Clicked Object

I have a top down view of my level. I am placing several objects around the scene that the player clicks on and info pops up. When they click the object, I want the camera to zoom into that object, then click another button to zoom back to the full view. I am kind of getting this to work, but through the level blueprint as attached. Is there any way to attach this to the object’s blueprint, so I can place multiple of those objects around the scene. Right now I have to set up the move component for each individual object in the level blueprint. I am also having trouble figuring out how to reset the camera back to the initial position.

Assuming the top down camera has to return to the same position after each closeup, you could store the cameras initial position and rotation in variables in the begin play event, and then use those variables as input when resetting the camera.

Getting a zoom position and rotation from the clicked actor without having to set a target component for each, could be achieved by taking the clicked actors location and adding an offset to it before moving the camera component to the resulting position. Something like Actor location + (0,0,200) To put it 200 units above the root of the clicked actor.

That’s kind of what I was trying to do in the screen shot with regards to the offset. Is the screenshot the best way to locate the actor and move the camera to it? It seems to have a mind of its own. To me, the camera should move to the location of the object with the current setup, but it seems to have a mind of its own and move to some random location when I click the object.

I suspect the problem is that the component is being moved to a relative position. If the scene component of the camera actor is what the camera component is being placed in relation to, subtracting the location of the camera actor from the clicked actor location, and passing that result into the target relative location pin on the Move Component To node, should place the camera component in the same place the clicked actor is.

Ah, that math makes sense. The Move Component To still seems to have trouble with it though. I’m assuming because of the Target Relative Location node. If I use a Set Actor Location, the camera moves to the correct location, but the camera just jumps straight there. I like how the Move Component To moves the camera in a slow smooth motion and you can set the time it takes. Is there any similar way to do that with the Set Actor Location?

Here is a solution I used for a similar setup in the past.

The most important node here is the timeline called CameraMovementTiming (a name I gave it). The timeline drives the interpolation between two transforms via the value Interp Alpha which changes over time. It is triggered by the two events and continues to update the Update exec line until the timeline has completed its run.
The ease node is used for interpolation driven by a 0 to 1 value. In this case interpolating between two transforms. The drop down menu (Ease in Out) allows you to select a number of different interpolation styles.
I believe you could easily do the same with position alone, if you wish, interpolating between vectors instead. You just have to determine the starting and end point for the movement and store those values for the interpolation.