- Home /
Distance along one axis?
Hello. How can I check the distance between two objects and then compare it to a condition that only uses ONE axis?
Ex: (If object A is 10 units away from object B on the Y axis) {do something}
Comment
Best Answer
Answer by Mike 3 · Feb 02, 2011 at 01:34 AM
Assuming A and B are both Vector3 (transform.position for each object):
if (Mathf.Abs((A - B).y) >= 10) { /* do something */ }
Your answer
Follow this Question
Related Questions
Distance won't work 1 Answer
making an object stop responding with an object at a certain distance away 1 Answer
Closest position on path to an object 0 Answers
Find position of point beetween two objects on certain distance 1 Answer
Checking the distance between an instantiated object and an existing object 1 Answer