Hello,
I’m trying to move an object across the screen and exectute a function, once it crossed a certain spot.
The object is translating along the x-axis.
That’s what I got so far:
function Update () {
var translation = Time.deltaTime * -10;
var myObject = GameObject.Find("MovingObject");
myObject.transform.Translate (translation, 0, 0);
if (myObject.transform.position == Vector3(147,9,-215)) {
Debug.Log("object crossed a certain spot");
}
}
As I expected the “==” in my if statement just isn’t the right way to do it. Means, it doesn’t work
The object is moving and even though it comes across the specified coordinates, the console does not show my Debug.Log message.
If anyone has an idea, how to detect this, I’d be more than happy.
Thanks in advance.