Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Camera to follow and orbiting player

Discussion in 'Editor & General Support' started by DJ_JW, Nov 6, 2017.

  1. DJ_JW

    DJ_JW

    Joined:
    Apr 26, 2015
    Posts:
    24
    Hi team

    I tried to ask this on Unity Answers but cannot as the captcha is not working (error message where catpcha should be)

    Essentially I am trying to find a way to create camera that is a combination of a smooth follow camera and a orbit camera

    I have a player that orbits around a pole (think cylinder that is fixed in position) in the centre of my scene. The player is able to move up and down the pole as it orbits around at a "semi" fixed distance from the pole.
    I can get the player to orbit (move) around the pole and not move too far from the center of the pole and move up and down the pole but I cannot find a way to have the camera follow the player around the pole (but always face the pole) - think like a standard orbit camera but instead of using the mouse or orbit around, the camera follows the player.

    I am figuring their will be some magic maths to make this work but for the life of me cannot get my head around how to do it.

    I would just have the camera follow the player transform and "look" towards the pole, my biggest issue with this is that the player can be facing any arbitrary direction at any time (physics player controller) and this causes the camera to face in odd directions as the player changes direction.

    Can anyone point me in the best direction to achieve this, or has someone already created a camera controller to do this that they would be willing to share?

    Thanks in advance.
     
  2. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    523