Vector3.distance

Hey
I have a problem with some if statements.
I check to see if the distance between the door and the player is smaller than distance(var).
The problem is that it’s not triggering when im getting near enough. I have placed it in the update funktion.
Here’s the code, where the problem is:

		if(!doorOpened){
			if(Vector3.Distance(player.position, _myTransform.position) < distance){
				_display.enabled = true;
				if(Input.GetButton("Interact")){
					openDoor();
					_display.enabled = false;
				}
			}
			else{
				_display.enabled = false;
			}
		}

Hope you will help:smile:

Would be easier to use a trigger. Instead of that whole distance bit, just make an OnTriggerEnter function, make the trigger as big as you need it to be.