0 votes

Hi all,

The following code used to work perfectly in Godot 2.1 but I can't seem to find the alternative way to do it in Godot 3.x:

    extends RigidBody
    #-------------------------------------------------------------
    func _ready():
        # Called every time the node is added to the scene.
        # Initialization here
        set_process(true)
        pass
    #-------------------------------------------------------------
    func _input_event(camera, event, pos, normal, shape):
        if (event.type==InputEvent.MOUSE_BUTTON and event.pressed):
            print("Object touched !")
        pass
    #-------------------------------------------------------------

In both case the rigid object has a mesh and collision shape as child.

PS: I don't want to detect a generic touch screen event but exactly when this mesh is touched.

Thx in advance.

in Engine by (849 points)
retagged by

The following code is working in godot3.x in another test scene but not in the main scene :-(

extends RigidBody

func _ready():
    # Called every time the node is added to the scene.
    # Initialization here
    set_process(true)
    pass
#-------------------------------------------------------------
func _input_event(camera, event, pos, normal, shape):
    if (event is InputEventMouseButton and event.is_pressed() == true):
        var parentName = get_parent().name
        print("Object touched :" + parentName)
    pass

Seems like the event is not propagated to the sub (initiated) scene ?

Please log in or register to answer this question.

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.