• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Short distance teleportation help.

pixeltroid

Member
I am trying to design a mechanic where the player fires a projectile "obj_teleporter" which lasts for around 2 seconds. If the player presses a button, obj_teleporter stops in place and the player dashes towards it's X and Y co-ordinates. I have something right now. It kind of works but not so well. As you can see I am using the move_towards_point function.

GML:
if teleporter = true { //condition for being able to teleport
if (keyboard_check(ord('L'))) {
with obj_teleporter {
speed = 0 //stops obj_teleporter in it's position
}
move_towards_point(obj_teleporter.x, obj_teleporter.y, 8); //this works only if the object is a certain distance away.
}
}
else {
speed = 0
}

Edit: It "kind of" works in the sense the player moves towards obj_teleporter, and obj_teleporter self destructs as intended. But there are problems in how the player moves when I press the button. For example, he reaches it, but instead of stopping, continues moving for a while until the obj_teleporter self destructs.

I'm trying to make it so that the player stops moving as soon as he reaches obj_teleporter's X and Y.

How do I achieve the effect I'm trying to?

Any help would be appreciated.
 
Last edited:

pixeltroid

Member
How would that be, and how does this differ from what you're trying to achieve?
it "kind of" works in the sense the player moves towards obj_teleporter, and obj_teleporter self destructs as intended. But there are problems in how the player moves when I press the button. For example, he reaches it, but instead of stopping, continues moving for a while until the obj_teleporter self destructs.

I'm trying to make it so that the player stops moving as soon as he reaches obj_teleporter's X and Y.
 

woods

Member
wouldnt this stop your player when he touches the TP?

obj_player
step event

if(place_meeting (x,y,obj_teleporter))
{
speed = 0;
}
 
Top