- Home /
Question by
danielg8 · Jan 21, 2019 at 03:18 PM ·
vector22d platformerside
How to check if a game object is located on the right/left side of another in 2D
Hi. I am pretty new to unity and c# and I want to know if it is possible to check which side a game object is on relative to another in 2D? It'll solve so many of my game issues. Thanks!
Comment
Answer by xxmariofer · Jan 21, 2019 at 03:21 PM
just compare the position x component of each gameobject, if object1.position.x is higher than object2.position.x then object one is in the right.