0 votes
func _on_Area2D8_body_entered(body):
if Input.is_action_pressed("opendoor"):

this code it triggering instantly upon scene load. I do have code to wait one frame under the _ready function. i want it to trigger only when the player (KinematicBody2D) enters the area2d. The player does not spawn on an area2d.

in Engine by (147 points)

2 Answers

0 votes

maybe its colliding with something else

try to check if its the player it is detecting
body.get_name() == "PlayerName"

or better

try to have a dedicated collision layer for your player and change the collision mask of your detectors to that

by (398 points)
+1 vote

I can confirm that problem. It seems to be some sort of bug in the engine.

You could try to use

yield(get_tree(), "idle_frame")

before adding the player to the scene.

Or set the initial position of the player to a very far away position, before adding it to the level and then setting it to the proper position, when entering the level.

by (196 points)

Guess who helped me big boy! YOU!! 5 hours on this one. Guess its those chumps fault ahahahah Knew it wasnt my code... No no no

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.