0 votes

I have no idea what could possibly be causing this, I have an Area2D with a collision shape and a sprite(which is part of a tilemap). I've connected the Area2D to the Sprite with the following code:

func _on_Area2D_body_entered(body):
if body.name == "Player":
    $AnimationPlayer.play("Checkpointed")
    body.spawn_point = position

The animation does play when the player comes in range, however it always spawns under the map.
I've also tried connecting the Area2D to itself and used the same code (dont know if that was smart), however the player just respawns in its "original" spawnpoint at the start of the map.

Any ideas?

in Engine by (32 points)

1 Answer

+1 vote

add a position 2D and instead of body.spawn_point = position do

body.spawn_point = $Position2D

place the Position2D where you want the player (or object) to spawn

by (126 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 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 webmaster@godotengine.org with your username.