I am developing a mobile game in ue4. For this project, I need to have a "static" camera so that the player can move within the frame not affecting camera location and rotation. But as this is an endless scroller I also need to have the camera move at a constant pace limiting the player's area of movement. Does anyone know how to do this?
\$\begingroup\$
\$\endgroup\$
4
-
1\$\begingroup\$ Am I correct to assume you currently have a camera that is follows the player? It's generally a good idea to provide your current situation as clearly as possible. If I understand correctly: you have a camera that follows the player, but you want to have it pointed in a static direction while giving it a fixed speed. Is that correct? If so, please edit your question to reflect that. If not, please edit your question to reflect what you've tried and where you're stuck. \$\endgroup\$Peethor– Peethor2019-04-14 10:14:08 +00:00Commented Apr 14, 2019 at 10:14
-
\$\begingroup\$ What specific part of this are you stuck on at the moment? The forward movement of the camera? The bounding of the player's movement? The movement of the bounds with the camera? \$\endgroup\$DMGregory– DMGregory ♦2019-04-14 12:39:07 +00:00Commented Apr 14, 2019 at 12:39
-
\$\begingroup\$ Basically everything because I can't break the link between the camera and the player. \$\endgroup\$Sigma 17– Sigma 172019-04-14 17:37:47 +00:00Commented Apr 14, 2019 at 17:37
-
\$\begingroup\$ Basically the camera is within the character blueprint and as a patent it will obviously follow the character and I don't want that. \$\endgroup\$Sigma 17– Sigma 172019-04-14 17:39:31 +00:00Commented Apr 14, 2019 at 17:39
Add a comment
|
2 Answers
\$\begingroup\$
\$\endgroup\$
I could think of two ways on how to solve your problem.
- Player-centered approach: Update the position of the static camera based on the position of the player pawn
e.g. in pseudocode assuming the player moves into the x direction:
Vector3 cam_to_player_distance = {0, 100.0f, 100.0f};
cam_position = player_pawn.getActorLocation() + cam_to_player_distance;
- Camera-centered approach: (my choice)
Make the camera the controlled pawn and add the runner as a child actor. Now you can freely move the runner to the left and right and without the camera being affected
\$\begingroup\$
\$\endgroup\$
5
Greatings, the trick is not moving the player but the level.
-
\$\begingroup\$ That is a trick. You could simply give the camera a fixed (or even variable) speed. \$\endgroup\$Peethor– Peethor2019-04-14 10:10:43 +00:00Commented Apr 14, 2019 at 10:10
-
1\$\begingroup\$ One line answers are generally incomplete. How would they achieve this? \$\endgroup\$2019-04-14 11:45:06 +00:00Commented Apr 14, 2019 at 11:45
-
\$\begingroup\$ Also, yes, it's a "trick", but the general consensus is still to move the camera. \$\endgroup\$2019-04-14 12:13:18 +00:00Commented Apr 14, 2019 at 12:13
-
\$\begingroup\$ It absolutely needs to be moving to my project \$\endgroup\$Sigma 17– Sigma 172019-04-14 13:54:36 +00:00Commented Apr 14, 2019 at 13:54
-
\$\begingroup\$ Peethor the problem is how to do this since the camer need's to be parented to the character and it can't be the character's root \$\endgroup\$Sigma 17– Sigma 172019-04-14 14:00:02 +00:00Commented Apr 14, 2019 at 14:00