Download

Let the camera follow the Character

In my UE4 top-down game the player controls the main character. The camera always has to follow the character’s movement.
What would be the best way to attach the camera to the character, while keeping its current rotation and direction?

Do you mean keep the camera in place, and not change location, but only aim at the player?

EDIT: Made a vid to see if this is what you meant:
https://www.youtube.com/watch?v=ksJillYiRDI&feature=youtu.be

No, the camera should always look top-down, exactly perpendicular to the floor plane, directly at the character and following its movement. That is, the camera moves like the character does. Think of a top-down 2D game.

Would it be a good solution to parent a spring arm to the camera in the BP components?

In that case, just change the camera rotation & location in the character BP. Super simple… That is, if I understood correctly

Thanks for your reply. But is it sufficient to attach the camera to a spring arm component, or do I need to also set its location from with in the BP?

Well, isn’t the camera attached to the spring arm by default in the topdown project?

Just to be sure, is this what you want?

Sorry if not…

https://www.youtube.com/watch?v=Ph4QkP_xNUU&feature=youtu.be

Yes, this is exactly what I want to achieve. Is that the default behaviour of the top-down example project?
If so then I am sorry. I was not able to test it yet as I am running on Linux at the moment without access to a working Unreal Editor.

That brings me to another question. Think of a floor plane on which the player character can move/walk. The character could move to the edge of that plane, the camera following it. When the character is close enough to the plane’s edge and the camera following it, then the player could see what is “behind” the plane’s edge.

How can I avoid this, so that the camera viewport only shows the plane, and never move further so that it would show what is behind the plane? Would I use the Camera Blocking Volume for such a case?

Thanks for your help!

Yes, this behaviour is default. Simply rotate the camera in the character BP viewport to face down, and move its location to be directly over the player.

And if I understand right… To prevent the camera from going inside of a mesh/wall/whatever to see what’s behind, all ya gotta do is set the mesh/wall/whatever to be able to collide with the camera so it can’t pass through.

Ok, I will try that as soon as I get back to my Windows machine.
Thanks vanlacke for your help!

How are you doing this? Are you getting the angle between the camera and the player and rotating the camera towards the character or are you somehow manipulating the spring arm component?