![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | KLDGZ |
Hello there Geniuses!, I’m very new to Godot and its script, however i was able to decently do some functions and am currently in the process of making a game. I was able to make something of an animated popup whenever my player walks into a collision.(Its basically a floating exclamation point in a chatbubble). I was able to do this by hiding the animated sprite and using signal codes like this :
onready var animatedSprite = $AnimatedSprite
func _on_WBSPrompt_area_entered(area):
$AnimatedSprite.visible = true
animatedSprite.play(“default”)
func _on_WBSPrompt_area_exited(area):
$AnimatedSprite.visible = false
And it works perfectly.
Now I’m trying to make it so that when I press a key it will go to a new scene or instance a scene (like dialogue or a zoomed version of it). I tried using:
func _on_WBSPrompt_area_entered(area):
$AnimatedSprite.visible = true
animatedSprite.play(“default”)
if Input.is_action_pressed(Insert Key):
get_tree().change_scene(“Insert Scene”)
But it informs me of an error saying that i cant use the area entered function like that.
I’m confused, is there a specific node or script that uses layers, that can read both collision of my player and a key. and yes I’m using a kinematic2dplayer with a normal collision box and an Area2D box for the area entered function.
I heard of using a Raycast2D node but even with the documents on it I’m completely lost.
Is there any way of doing this or at least a node that can assist with this.
Thank you for hearing me out and I hope the answers can help anyone who was wondering about a similar problem.