Roll A Ball Tutorial

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 :smile:) 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?

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.

3 Likes

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.

@Stevew82 You are correct. A child object becomes relative to its parent transform. This can be useful when positioning objects.

1 Like

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.

1 Like

Thanks for your response guys :smile:

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.