I have a problem.
The distance check works fine in the editor, however, I have to run it, stop it and then run it again for its work. As well as that, it is completely broken on a build (buttons can be pressed from any distance).
The code:
public class UpToLevel : MonoBehaviour {
private GameObject player;
void Update()
{
player = GameObject.Find("FPSController");
var distance = Vector3.Distance(player.transform.position, transform.position);
//print (distance);
}
void OnMouseDown()
{
var distance = Vector3.Distance(player.transform.position, transform.position);
if (distance > 3.0)
{
SceneManager.LoadScene("DemoLevel");
}
}
Any help? Built to Windows x86_64