0 votes

hi, i have a question, i have a scene called door, when the player collides with the door, my code verify if is the player, if is the player the script change the scene, but i was implementing a skin system that use scenes as prefabs, but now i can't use the old code, idk how to explain, im not a native english speaker, i guess my code will explain better:

func _physics_process(delta):
var bodies = get_overlapping_bodies()
for body in bodies:
    if "Player" in body.get_name():
        if Globals.isDark == true:
            get_tree().change_scene(world_scene)
        else:
            get_tree().reload_current_scene()

pass

like, i need to check only if is "player" in the name of the scene but this code doesn't work

in Engine by (20 points)

1 Answer

+1 vote
Best answer

you can use collision layers and collision masks
https://www.youtube.com/watch?v=AyzMkCWaB1c&t=1506s
maybe it will help you

by (290 points)
selected by
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.