Inputs not detected in body_entered func?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LowRes Studios

Im very new to Godot and GDScript so this might just be a mistake on my half but it seems that the Input feature is not working in a curtain function.

Here’s my script :
extends Spatial

func _ready(): pass

func _on_Invisble_Collision_Door_Room_YOU_body_entered(body):
if body is KinematicBody and Input.is_action_just_pressed("interact"):

I have got rid of the imput part of the script Input.is_action_just_pressed("interact") and it works just fine with collisions but Input isn’t working in the func.

BTW, Indents are there in the code.

Anyone has any help, it is very appreciated.

:bust_in_silhouette: Reply From: Biam

For doors, I like to use get_overlapping_bodies()
Try putting this in your function:

var bodies = get_overlapping_bodies()
for body in bodies: 
	if == "KinematicBody": 
		if Input.is_action_pressed("interact"):"DoorOpen")

I don’t completely understand but i tried to implement it anyway.
This is what i ended up with :

extends Spartial

func _ready():

func _process(delta):

func _on_Invisible_Collision_Door_Room_YOU_body_entered(body):
    var bodies = get_overlapping_bodies()
    for body in bodies:
        if == KinematicBody:
            if Input.is_action_just_pressed("interact"):

That is the full script but it still doesn’t work and once again i got rid of if Input.is_action_just_pressed("interact"): but this time getting rid of it doesn’t help.

If you could, can you link me to a tutorial or a example project

Thanks, Joe

LowRes Studios | 2018-06-04 19:04

:bust_in_silhouette: Reply From: eons

´just_pressed´ (or Input in general) may never work while signals are processed, you need to check it on process and store in a variable until next process.

Another approach is to assign the door to the node that has the open option, remove it on body exit.
Process the input and activate the item that is being touched if there is any.