As in you bring units to the edge of the map and they re-appear on the otherside at the equivelant location based on where you were on the other side. I need this for an arcade jumping game I'm making. How would you do it? I know the basic triggers(unit enters region, move unit to other region), but how would you get the units to re-appear on the other side at the exact location they we're on the side they came from? It sounds confusing but hopefully someone gets what I need.
- Thanks
Edit: I know you could just make a region for every large square on the grid and do it individually, but that would take ages and I honestly don't have the patience.
To get a unit to teleport to the other side of the map, first, you're going to have to make a thin region around the whole "border" of your map. Just do a simple "if unit enters region then move instantly to point" trigger, but for the "Point" part of it, use a custom script based on something like this:
Point( PointGetX( UnitGetPosition(EventUnit() ), PointGetY( UnitGetPosition( EventUnit() ) ) )
Which works like Point(x,y). So if your unit enter the right region and you want him to teleport to the left side of the map, use Point( 0 , PointGetY(UnitGetPosition(EventUnit())) ), or whatever the X unit is that the left of the map is at (trial and error here).
The bottom left part of the map is (0,0).
Or in the gui do a "set variable" action and set a real variable to equal the x/y position, found under the "X/Y of Point" function. Then plug in those variables for the point of teleportation.
You'll need four thin regions along the borders to detect units going into them, and a trigger for each one that moves it to the opposite side.
Example:
Events
Unit - Any Unit Enters Left Border Region
Local Variables
Conditions
Actions
Unit - Move (Triggering unit) instantly to (Point(((X of (Position of (Triggering unit))) + 250.0), (Y of (Position of (Triggering unit))))) (No Blend)
That trigger is for a map that's 256 x 256. It'll keep his Y coordinates the same and will move his X coordinates to the opposite side of the map. Just make sure that the unit doesn't get teleported into the border region on the other side, otherwise it would teleport endlessly between both sides and you'd create a black hole or something.
You'll need four thin regions along the borders to detect units going into them, and a trigger for each one that moves it to the opposite side. Example:
Events
Unit - Any Unit Enters Left Border Region
Local Variables
Conditions
Actions
Unit - Move (Triggering unit) instantly to (Point(((X of (Position of (Triggering unit))) + 250.0), (Y of (Position of (Triggering unit))))) (No Blend)
That trigger is for a map that's 256 x 256. It'll keep his Y coordinates the same and will move his X coordinates to the opposite side of the map. Just make sure that the unit doesn't get teleported into the border region on the other side, otherwise it would teleport endlessly between both sides and you'd create a black hole or something.
You mean I'd create...
TerribleTERRIBLEDAMAGE! D:
But uh, so how do I figure out the x or y values if my size is smaller (like A LOT smaller) than your example, whats the equation? Just 6 less than the dimension or what?
Depends on your map size and the size of your border regions. In my example it gives the region about 5 points of lee-way, that way the unit ends up being right outside the region on the other side. You can measure the size of the region and what the X point your unit needs to be at just by moving your cursor over it in the editor, it shows the X,Y,Z (In that order) location of the cursor at the bottom left on the bar.
Just note that when moving to the other side you would need to make it the opposite operator ( - 250 instead of + 250) and for the top and bottom borders you would be doing that for Y instead of X.
Edit: Oh and you'll also have to add the factor of the region he's going into in the equation. The unit won't be at exactly 256 when it hits the border most likely, it will be at the edge of the border region. Forgot to take that into account.
Also try not to end up having the unit teleport back and forth in a continous loop. So you should teleport the unit a little outside the border regions.
Also try not to end up having the unit teleport back and forth in a continous loop. So you should teleport the unit a little outside the border regions.
Lmao, after some trial and error I got it to work, but in the beginning I had it continuously looping back and forth, which was pretty funny. It actually allows you to fly off of normal walkable ground and into un-walkable areas on the map, like space. Pretty cool but not what I was looking for. The only problem I'm having now is the fact that the camera (which has it's follow speed set to something like 1250 right now) does not follow the unit it is supposed to follow fast enough between the jumps. The unit briefly appears off screen and that can't happen in the real version as it would end up screwing people over. I've tried setting the default camera zoom to -40 and that doesn't help. Before this I only needed the zoom at about 400 to follow it without being choppy, but now that it is so high it is becoming slightly more choppy. Help??
As in you bring units to the edge of the map and they re-appear on the otherside at the equivelant location based on where you were on the other side. I need this for an arcade jumping game I'm making. How would you do it? I know the basic triggers(unit enters region, move unit to other region), but how would you get the units to re-appear on the other side at the exact location they we're on the side they came from? It sounds confusing but hopefully someone gets what I need.
- Thanks
Edit: I know you could just make a region for every large square on the grid and do it individually, but that would take ages and I honestly don't have the patience.
@ST4RKiLL3R: Go
Save the Y coordinate if they're moving horizontally and save the X coordinate if they're moving vertically.
@Sephiex: Go
Which Triggers?
To get a unit to teleport to the other side of the map, first, you're going to have to make a thin region around the whole "border" of your map. Just do a simple "if unit enters region then move instantly to point" trigger, but for the "Point" part of it, use a custom script based on something like this:
Point( PointGetX( UnitGetPosition(EventUnit() ), PointGetY( UnitGetPosition( EventUnit() ) ) )
Which works like Point(x,y). So if your unit enter the right region and you want him to teleport to the left side of the map, use Point( 0 , PointGetY(UnitGetPosition(EventUnit())) ), or whatever the X unit is that the left of the map is at (trial and error here).
The bottom left part of the map is (0,0).
Or in the gui do a "set variable" action and set a real variable to equal the x/y position, found under the "X/Y of Point" function. Then plug in those variables for the point of teleportation.
@ST4RKiLL3R: Go
You'll need four thin regions along the borders to detect units going into them, and a trigger for each one that moves it to the opposite side. Example:
Events
Unit - Any Unit Enters Left Border Region
Local Variables
Conditions
Actions
Unit - Move (Triggering unit) instantly to (Point(((X of (Position of (Triggering unit))) + 250.0), (Y of (Position of (Triggering unit))))) (No Blend)
That trigger is for a map that's 256 x 256. It'll keep his Y coordinates the same and will move his X coordinates to the opposite side of the map. Just make sure that the unit doesn't get teleported into the border region on the other side, otherwise it would teleport endlessly between both sides and you'd create a black hole or something.
You mean I'd create...
Terrible TERRIBLE DAMAGE! D:
But uh, so how do I figure out the x or y values if my size is smaller (like A LOT smaller) than your example, whats the equation? Just 6 less than the dimension or what?
@ST4RKiLL3R: Go
Depends on your map size and the size of your border regions. In my example it gives the region about 5 points of lee-way, that way the unit ends up being right outside the region on the other side. You can measure the size of the region and what the X point your unit needs to be at just by moving your cursor over it in the editor, it shows the X,Y,Z (In that order) location of the cursor at the bottom left on the bar.
Just note that when moving to the other side you would need to make it the opposite operator ( - 250 instead of + 250) and for the top and bottom borders you would be doing that for Y instead of X.
Edit: Oh and you'll also have to add the factor of the region he's going into in the equation. The unit won't be at exactly 256 when it hits the border most likely, it will be at the edge of the border region. Forgot to take that into account.
Also try not to end up having the unit teleport back and forth in a continous loop. So you should teleport the unit a little outside the border regions.
Lmao, after some trial and error I got it to work, but in the beginning I had it continuously looping back and forth, which was pretty funny. It actually allows you to fly off of normal walkable ground and into un-walkable areas on the map, like space. Pretty cool but not what I was looking for. The only problem I'm having now is the fact that the camera (which has it's follow speed set to something like 1250 right now) does not follow the unit it is supposed to follow fast enough between the jumps. The unit briefly appears off screen and that can't happen in the real version as it would end up screwing people over. I've tried setting the default camera zoom to -40 and that doesn't help. Before this I only needed the zoom at about 400 to follow it without being choppy, but now that it is so high it is becoming slightly more choppy. Help??
@ST4RKiLL3R: Go
Instantly set the camera position (eye, I think) to the other side of the map, just like the unit.
Hadn't thought of this. Good idea. :D