1
\$\begingroup\$

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?

\$\endgroup\$
  • 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 Apr 14 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 Apr 14 at 12:39
  • \$\begingroup\$ Basically everything because I can't break the link between the camera and the player. \$\endgroup\$ – Sigma 17 Apr 14 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 Apr 14 at 17:39
1
\$\begingroup\$

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

\$\endgroup\$
-3
\$\begingroup\$

Greatings, the trick is not moving the player but the level.

\$\endgroup\$
  • \$\begingroup\$ That is a trick. You could simply give the camera a fixed (or even variable) speed. \$\endgroup\$ – Peethor Apr 14 at 10:10
  • 1
    \$\begingroup\$ One line answers are generally incomplete. How would they achieve this? \$\endgroup\$ – Vaillancourt Apr 14 at 11:45
  • \$\begingroup\$ Also, yes, it's a "trick", but the general consensus is still to move the camera. \$\endgroup\$ – Vaillancourt Apr 14 at 12:13
  • \$\begingroup\$ It absolutely needs to be moving to my project \$\endgroup\$ – Sigma 17 Apr 14 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 Apr 14 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.