+1 vote


So basically I need functionality as it is used in many 2D games.

I'd like to create an location/area that my character enters and then gets "beamed" into another spawn location/area.
This can also be useful for scene transitions in games where you can go back and forth.

Thanks a lot guys

P.S. Excuse me if I feel lazy, but I'm just starting out with GD Script / Python.

in Engine by (42 points)

2 Answers

+1 vote
Best answer

You could place a Node2D whose only purpose is to be used as position to spawn a player. To create the teleport entrance, use an Area2D node and connect its signal to a function that will move the player to the teleport destination (the Node2D's position).

by (12,653 points)
selected by

Also, a Position2D might be preferable to a pure Node2D, as it has a crosshair you can use to place it nicely and accurately but which won't be visible in the game.

+1 vote

In our game we use Position2d node as spawnposition.

For spawning enemy randomly on defined points we do it like this

spawnPoints = map.get_node("spawnPoints").get_children()

for enemy in enemys:
    var spawnIndex = randi() % spawnPoints.size()
    var spawnPoint = spawnPoints[spawnIndex]
    var pos = spawnPoint.get_global_pos()
by (693 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.