I'm trying to find the distance between two objects using transform.position.
Here is my code for the scripts:
using UnityEngine;
using System.Collections;
public class Trigger : MonoBehaviour {
public GameObject Door;
public GameObject Player;
int count = 0;
// Use this for initialization
void Start () {
Debug.Log (Door);
Debug.Log (Player);
}
// Update is called once per frame
void Update () {
Debug.Log (Door.transform.position);
//Debug.Log (Door);
//Debug.Log (Player);
//float distance = Vector3.Distance (Door.transform.position, Player.transform.position);
//Debug.Log (distance);
}
And here is an image showing 1) the scene and hierarchy 2) the inspector for the gameobject ive assigned the script to:
However the problem is now when i want to find the position of that object however it only returns the initial position - ie it's not updating the position of the gameObject player - how can i update the gameObject variable?