4.2.2 Windows 10
I’m a beginner and I’m encountering an issue with
detecting player entry. It prints “Player has entered” immediately every time the game starts. Why does this happen? Though when I move the player into the area, the entered and exited signals work properly.
extends StaticBody2D
Called when the node enters the scene tree for the first time.
func _ready() → void:
pass # Replace with function body.
Called every frame. ‘delta’ is the elapsed time since the previous frame.
func _process(delta: float) → void:
pass
func _on_area_2d_body_entered(body: Node2D) → void:
print(body)
print(“1”)
pass # Replace with function body.
func _on_area_2d_body_exited(body: Node2D) → void:
print(body)
print(“2”)
pass # Replace with function body.
extends CharacterBody2D
func _process(_delta: float) → void:
var direction_a = Input.get_vector(“left”,“right”,“up”,“down”)
velocity = direction_a * 300
move_and_slide()