Hi,
i’m new to Unity and scripting.
I try to make a simple script to compare distance between two objects: obj_test and player.
Can someone tell me why this doesn’t work? I searched a lot but did not found any answer. Thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour {
public GameObject player;
public GameObject me;
public float distance;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
distance = Vector3.Distance(player.transform.position, me.transform.position);
if (distance >= 10)
{
Debug.Log("yo man!");
}
}
}