public GameObject ItemThatFalls;
public Transform ObjectCantGoBy;
void Update () {
{
if (ItemThatFalls.transform.position.y == ObjectCantGoBy.transform.position.y) {
Debug.Log ("Wood is at 22");
} } } }
So I want a if statement to happen if "ItemThatFalls"s falls, and if it reaches "ObjectCantGoBy"s “y” axis, I want the if statement to happen.
Note that in Unity, the transform positions are almost never exact, so I wouldn’t make the statement true if they are exactly the same. Since you named one ItemThatFalls, I’ll assume it’s going down, so you’d want to replace == with <= (less than or equal to).
Code cleaned up:
void Update ()
{
if (ItemThatFalls.transform.position.y <= ObjectCantGoBy.transform.position.y)
{
Debug.Log ("Wood is at 22");
}
}
Hey thanks for the information, Any Idea on how to call a prefab so if anything within that prefab goes through that Y axis, it will run the If command