How can I make an playable character (object) teleport instantly without a teleporter?

Hey!!! I trying to make a fighting game, and I want one of the characters to be able to teleport without a teleporter. Like, I want the player to be able to press a button, and the character teleports in a different destination. Is that possible?

Can you add more info? What type of game? Top down, platform? How are you moving the player?

Moving a character to a preset location is easy, add a bunch of hidden objects and then pick a random object and move the player there. This is safe because you would know that the location was valid.

Using completely random locations is more difficult because you would need to find a valid location. You could move the object to a random X,Y either based on the scene or screen size or choose a location in a random angle and distance from the current position. Again, making sure the location is valid.

There are several ways to check for a valid location. You can use brute force and keep adding or moving the character until it’s not in collision with an object in a group list or you could move the object and then use the separate objects action. The only issue is making sure the player couldn’t be put in a weird area or a place where it could get stuck.

You could combine both approaches and add objects like zones. Pick a random zone and then pick a random x,y based on its bounding box. This would be a little more controlled.

It’s difficult without knowing more about your game. If it had a lake, you could drop the player into it. You could then either try to separate it or pick another location and try again.

1 Like

Sorry for not clarifying, the game is going to being like a platformer, just not as big as one. I’m looking for a way for my character to teleport anytime/at the location(wherever) there at in a current amount away from their original position. And i want the player to be able to teleport the character by pushing a button. I was hopping theres a way where character doesn’t have to use a teleporter to teleport, since it doesnt move with the character.

Can you share a screenshot of the scene for refernce? Can they teleport to another platform? How do they choose where to go?

What do mean by teleporter? Objects can be moved with the position actions. You just need to be careful where you move them to so they don’t “teleport” inside another object.

This is very possible in two different methods. For one, you could add the extension or whatever it is that I think I saw earlier, and make the screen move when the mouse is at the edge, and you could turn down the opacity of the player, adding some red-tinted effect or something whenever in collision with a platform, and turn off your player’s platformer behavior until enter is pressed, in which case, the opacity will be put back. If center camera on player doesn’t work in reverse, then you’ll have to make that happen, too.

Or you could have various teleporters, and whenever you press the button that is supposed to put the player at a certain checkpoint, the player’s position is set to the position of that checkpoint/portal.

Which method you use depends on how free you want the teleportation to be.