Search Unity

Camera following player script.

Discussion in 'Scripting' started by gamerant, Aug 30, 2013.

  1. gamerant

    gamerant

    Joined:
    Jun 27, 2013
    Posts:
    16
    Hello there.

    I came across an issue which I can't seem to resolve.Here it is:
    I would like the main camera in the game to follow the player,but rotate only when the platform that the player is on rotates.I guess another way of putting this would be: I'd like to have the camera follow the position of the player but the rotation of the platform.

    I tried parenting but that didn't get me anywhere.So i think i was doing something wrong.

    If anyone has any suggestions or tips of how to achieve this it would be greatly appreciated.
     
  2. Tiggster

    Tiggster

    Joined:
    May 22, 2013
    Posts:
    29
    Why not attach a script to your main camera which updates the position on the camera transform to that of the player and the camera transform rotation to the rotation of the platform transform? You could use the Update() function to do this.
     
  3. gamerant

    gamerant

    Joined:
    Jun 27, 2013
    Posts:
    16
    Could you send me on the right path by giving a short example?
    I'm not that great at coding yet so I have trouble figuring out how to write some pieces of code. :p

    EDIT:The problem is fixed.Thank you for the help.
     
    Last edited: Sep 14, 2013