> SecondDimension , —
This is a simple way to do it.
DON'T rotate the layer, on which the player or Arrow or whatever is this way, since the rotation is not centered. It confuses the coordinates.
Rather rotate everything around the player in the center of the map.
You can also let the arrow easily disappear, if target "is on-screen", or when the distance (rather of the XY coordinates, as done in the file, not the function dist(), as this would detect a circle, but you have a square Screen) of the halfway point being smaller than your View-Port-edges.
Hope it helps...
Hey man, thanks so much for your time on this - Unfortunately rotating the layer is something I have to do. 14 months of development already built around the layers rotating, it would be too time consuming to switch it so everything rotates around the player.
Also, in regards to the code above, its nice for sure, i like how it smoothly transitions from the object to the screen edge, but yeah without the rotation i just cant use it.
i was trying to account for the rotation using transform/rotate trigonometry functions but i barely knew what I was doing, so it ended up messed up.
p = ViewportRight/2
q = ViewportBottom/2
(so now p,q is the exact centrepoint of the viewport)
newx=(x-p)*cos(?)-(y-q)*sin(?)+p
newy=(x-p)*sin(?)+(y-q)*cos(?)+q