Need help with teleportation function for correct jump

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

So, im trying to make a thing. As we all tend to do. What I want this thing to do is either teleport me to the left or the right by X meters, simple enough.

What I am not sure on is this. Lets say you are within X meters of the edge of the sim and the sim edge is on your left side. If you then activate the thing I want it to detect that the edge of the sim is on your left and then jump you to the right. Same if the sim edge is on your right, jump you to the left. What is the best way to achieve this so the script detects the sim edge, your distance and which way you are facing from it and then perform the jump accordingly. I also need to figure out how to make it so it detects the side of the sim if say your at a 45deg angle to it. What I am trying to achieve is making sure the jump doesn't plonk you at the edge of the sim or fail as the coordinates are not valid. So, lets say even at a 45deg angle theres a chance you could still try to teleport off sim.

Share on other sites

So, calculate the jump target position and then ask whether its X coordinate or Y coordinate lies outside the acceptable limits [ 0 ... 256].  If so, you know that you can't go that way, so go in the exact opposite direction.

Share on other sites

2 minutes ago, Rolig Loon said:

So, calculate the jump target position and then ask whether its X coordinate or Y coordinate lies outside the acceptable limits [ 0 ... 256].  If so, you know that you can't go that way, so go in the exact opposite direction.

Of course....thank you. I was over complicating it in my mind, now you say that im having a "duh..." moment. Thanks Rolig

Share on other sites

To be precise, instead of saying that you should "go in the exact opposite direction," I should have said to mirror the offending X or Y coordinate.  After all, suppose that you are standing at <246.0, 2.5, 22.0>, in the SE corner of the region and the calculated jump target turns out to be <266.0, 5.0,22.0>.   Moving to the "exact opposite direction" would put you at <236.0,-2.5,22.0>, which is still outside the region.  What you want to do is recognize that the X direction is unreachable, but the Y is fine.  So accept the Y, multiply the X by -1, and move to <236, 5.0, 22.0>.

Edited by Rolig Loon
typos. as always.
• 1