Search Unity

Roll A Ball Tutorial

Discussion in 'Getting Started' started by Stevew82, Sep 26, 2015.

Thread Status:
Not open for further replies.
  1. Stevew82

    Stevew82

    Joined:
    Sep 24, 2015
    Posts:
    11
    hi all! so i'm currently on the third tutorial video for the Roll A Ball game and it's been pretty fun (though I really want to get to that space shoot :D) but i'm feeling a bit dumb. in the third video, we attach the main camera as a child to the player object. this results in the camera rotating like crazy as the ball rolls over all the axes. we are then instructed to detach the main camera and write a script. now obliviously the scripts works fine, but whats bugging me is I don't understand what the hell the guy is talking about at this point. the offset is the difference between the cameras position transform and the player objects position transform. great, but I don't know why that stops the camera from rotating. I've rewatched this several times to see if it clicks, but i still haven't had that eureka moment yet. Can someone explain whats going on a little clearer here?
     
  2. Stevew82

    Stevew82

    Joined:
    Sep 24, 2015
    Posts:
    11
    Hmm think i've got it. When we detach the camera as a child, it no longer stays relative to the ball (which was rolling on all three axis hence the camera spin) so in order to track the sphere, we have to write a script that calculates the camera tracking itself. or something lol.
     
    starlock, Xenoun and Kiwasi like this.
  3. starlock

    starlock

    Joined:
    Oct 31, 2014
    Posts:
    5
    Yeah I reckon so, I've just watched these and pretty much gathered the same. I think it's normally fine to attach the camera as a child in a 3rd person perspective, only not in the case of a roller ball moving on all three axis.
     
  4. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @Stevew82 You are correct. A child object becomes relative to its parent transform. This can be useful when positioning objects.
     
    holliebuckets likes this.
  5. james_m_russell

    james_m_russell

    Joined:
    Jun 2, 2015
    Posts:
    25
    remember - transform is not only location on the x,y,z but also rotation and scale. anything you do to the parent, will affect the children game objects.
     
    starlock likes this.
  6. Stevew82

    Stevew82

    Joined:
    Sep 24, 2015
    Posts:
    11
    Thanks for your response guys :D
     
  7. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, you got it right. When the camera is a child of the ball, it's transform (position, rotation and scale) are relative to its parent. We only want relative position, not relative rotation, so we write a script that takes only position into account.

    Please refer to the official Q&A threads in the teaching section when discussing Unity learn projects.
     
Thread Status:
Not open for further replies.