Search Unity

Please explain why this camera script doesn't work, what am I missing here?

Discussion in '2D' started by JustaDuck97, Oct 11, 2019.

  1. JustaDuck97

    JustaDuck97

    Joined:
    Jul 31, 2019
    Posts:
    45
    Code (CSharp):
    1. public class FollowPlayer : MonoBehaviour
    2. {
    3.     //Variables
    4.     public Transform player;
    5.     public Vector3 Offset;
    6.     void fixedupdate ()
    7.  
    8.     {
    9.         transform.position = player.position + Offset;
    10.      
    11.      
    12.     }
    I'm not opposed to a lengthy explanation. I'm just trying to learn.
     
  2. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    void fixedupdate () should be void FixedUpdate ()

    and don't use FixedUpdate for camera move or this can be "laggy". Use Update() (or LateUpdate for the camera scripts). FixedUpdate has fixed time steps and is used for the physics. Update is calling every frame. LateUpdate is calling every frame too but at the end.
     
  3. JustaDuck97

    JustaDuck97

    Joined:
    Jul 31, 2019
    Posts:
    45
    Oh, It's always something stupidly simple with me.