Hi, beginner here. I want to apply key & door to this First Person demo (FPP interation)
Basically (as I understand) the Player has raycast to check if the door has method "interact" then press a button to activate the door open animation
Player script
if Input.is_action_just_pressed("interact"):
if $Yaw/Camera/InteractionRay.is_colliding():
var x = $Yaw/Camera/InteractionRay.get_collider()
print("COLLIDING")
print(x.get_name())
if x.has_method("interact"):
x.interact(self)
Door script
func interact(relate):
if !animating:
if state == CLOSED:
$AnimationPlayer.play("open")
else:
$AnimationPlayer.play_backwards("open")
What I try was add a key variable to the door and a Key object with script
func interact(relate):
get_node("/root/Main/Street/Door/Door").key = true
then change the door script to
var key = false
func interact(relate):
if !animating:
if state == CLOSED && key == true:
$AnimationPlayer.play("open")
It's not working obviously and I have no idea how to do this correctly or is that a better way, Please help!