Having trouble setting a variable using this code.
The xmin and max are later used to clamp movement to the xaxis in the player space.
At the moment debug logs are returning the vales as what they were initially set too.
There is only 1 camera in the scene tagged as maincamera.
Any ideas on what might be wrong? nothing I am trying seems to work.
private float xmax = 5;
private float xmin = -5;
void start(){
Camera camera = Camera.main;
float distance = transform.position.z - camera.transform.position.z;
xmin = camera.ViewportToWorldPoint (new Vector3 (0, 0, distance)).x;
xmax = camera.ViewportToWorldPoint (new Vector3 (1, 1, distance)).x;
}
Perfect, thankyou.
– Proffasaurus