I have two gameobjects. One functions as a reference for the axes. The other one will have script attached to it that will determine what axis it is lying on. Any idea how I could find that info? I’ve tried if(someGameObject2.transform.position.y == someGameObject.transform.position.y) but that if statement is comparing values and someGameObject’s axes could have the exact same value such as (0,0,0). I have some pseudo code written up. I’m just not sure what I want to compare to see if one gameobject is on the y axis of another gameobject
using UnityEngine;
using System.Collections;
public class AxisChecker : MonoBehaviour {
public GameObject someGameObject;
public GameObject someGameObject2;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
/*if(someGameObject2 is lying on someGameObject.transform.x)
Debug.Log("someGameObject2 is lying on someGameObject's x axis");
if(someGameObject2 is lying on someGameObject.transform.y)
Debug.Log("someGameObject2 is lying on someGameObject's y axis");
if(someGameObject2 is lying on someGameObject.transform.z)
Debug.Log("someGameObject2 is lying on someGameObject's z axis");
*/
}
}