roll-a-ball camera offset problem

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:

public class GameController : MonoBehaviour {
public GameObject player;
private Vector3 offset;
void start () {
   offset = transform.position;
  }
void LateUpdate () {
   transform.position = player.transform.position + offset;
  }
}

Thanks
Jeff

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

Regards

Yes changing start to Start resolved it!! I knew it was probably something simple I was missing.

Thanks a lot :slight_smile:

PS - I fixed the posted code with code tags.

1 Like

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.