I'm trying to figure out how to get a value.
I have an object at position X 100 . Y 100
and another object 20 pixels above and 30 pixels to the left. X 70 . Y 80
How do i get the relative value of -30 and -20 from these two?
I want to return the difference between two XY positions.
Just can't figure it out.
Develop games in your browser. Powerful, performant & highly capable.
relativePositionX = object.x - anotherObject.x
relativePositionY = object.y - anotherObject.y
If you want distance then relativeDistance = distance(object.x,object.y,anotherObject.x,anotherObject.y)