Math to move camera

Hello everyone!

Kind of struggling to achieve a smooth camera movement, mostly I am having a hard time to define all the math that goes into it and so I am here to ask all of you help with the math part.

Ideally, what I would like to achieve is this:
I have a character in a position. Let’s say that the position is (0,0,0).
I would like to have a camera facing the character. The camera should then move upward in a spiraling movement and at the same time keep the focus on the character’s head (so I guess adjust the pitch value of the camera).

Ideally, I would like to have variables to store the following information:

  • how many “steps” to achieve a full 360-degree rotation
  • how many 360-degree full rotations
  • how much the camera should move upwards after completing a whole rotation. So, for example if the camera starts at z=0, after the first rotation it should be at z=0.2, and then z=0.4 at the end of the second rotation and so on until it reaches the max number of rotations and always pointing to the character

How can this be achieved?
Hope I have been clear, if not please let me know.
Thank you all for the help!

Dan

I have difficulty visualizing what you mean by this so could you explain it more?

Sure thing!
I have attached an image to help.
Let’s say that the character is standing on the z axis and the camera is on the x axis looking at the character.

helix

The math to create the movement is still a challenge.

Sorry for taking long to respond. If you still have this problem, I might have some ideas on how to implement this. I would not do much math myself for this.

I would use a spring arm component that is in the centre and attach a camera to it. Then I would spin the spring arm while moving it upwards. I believe this would create this type of spiral movement. For making this smooth you can use the lag setting in the spring arm.

For making the camera always face player I would use this UKismetMathLibrary::FindLookAtRotation | Unreal Engine Documentation. Maybe only use pitch value from this.

Never actually done anything like this so no idea if this works for you but I hope this is helpful.

Hi @Mikapo
I can totally use your suggestions and achieve what I need.
In my free time I will still try to work on the math for fun, but thank you for your hints! Have been really helpful!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms