Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

roll-a-ball camera offset problem

Discussion in 'Getting Started' started by jshrek, Feb 10, 2015.

  1. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    Hi

    Just installed Unity3D on my Mac earlier today and am going thru the roll-a-ball tutorial but am having a problem with the camera offset.

    When I run the game, the camera seems to jump to the same location as the ball, as opposed to being offset by initial positioning.

    Has anybody else experienced this same issue?

    This is the c# GameController.cs file which I think is identical to the one in the tutorial:

    Code (csharp):
    1. public class GameController : MonoBehaviour {
    2. public GameObject player;
    3. private Vector3 offset;
    4. void start () {
    5.    offset = transform.position;
    6.   }
    7. void LateUpdate () {
    8.    transform.position = player.transform.position + offset;
    9.   }
    10. }
    Thanks
    Jeff
     
    Last edited: Feb 10, 2015
  2. kdubnz

    kdubnz

    Joined:
    Apr 19, 2014
    Posts:
    177
    The roll-a-ball script attached to the Camera is
    CameraController.cs ... but GameController.cs should be ok provided it IS attached to the Camera.

    your void start ()
    should be
    void Start ()

    Because you aren't using the correct function, the offset variable will retain it's default values from the initialize statement
    .. which I assume is 0, 0, 0

    Also, regarding formatting code for the forums, please read here
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/

    Regards
     
  3. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    Yes changing start to Start resolved it!! I knew it was probably something simple I was missing.

    Thanks a lot :)

    PS - I fixed the posted code with code tags.
     
    Last edited: Feb 10, 2015
    Kiwasi likes this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Watch you case and spelling on the Unity magic methods. This is a very easy trap to fall prey to. And the compiler will give you no warnings or clues.