jshrek
February 10, 2015, 2:25am
1
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
kdubnz
February 10, 2015, 4:14am
2
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
If you see someone who needs to know about code tags, please link them to this post: Please use code tags when posting code. You can “tag” your code by typing around your code. There is no overt “Code” tag button that automatically tags a...
Reading time: 9 mins đź•‘
Likes: 83 ❤
Regards
jshrek
February 10, 2015, 12:56pm
3
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.
1 Like
Kiwasi
February 11, 2015, 5:37am
4
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.