godot 3.1 _input_event not working

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

In godot 3.0 this code works, in 3.1 don’t. Any ideas why?

   func _input_event(camera, event, pos, normal, shape):
    	if event is InputEventMouseButton \
    	and event.button_index == BUTTON_LEFT \
    	and event.is_pressed():
    		self.on_click()
    
    func on_click():
    	tileNode.click()

What is the error?

salihkallai | 2019-03-14 20:04

there is no error message, it don’t works :slight_smile: func on_click() is not executed

beetbeet | 2019-03-14 20:25

:bust_in_silhouette: Reply From: beetbeet

there is no error message, it don’t works :slight_smile: func on_click() is not executed

:bust_in_silhouette: Reply From: TyTYctA

Hi,
func _input_event(camera, event, pos, normal, shape) is a method of class CollisionObject

Class: CollisionObject
Inherited by: Area , PhysicsBody

the node has this script, must be a PhysicBody (KinematicBody , PhysicalBone , RigidBody , StaticBody) or an Area
and has a camera
enter image description here

then this function run normally

you can read more at InputEvent
at step 4:
If no one wanted the event so far, and a Camera is assigned to the Viewport, a ray to the physics world (in the ray direction from the click) will be cast. If this ray hits an object, it will call the CollisionObject._input_event() function in the relevant physics object (bodies receive this callback by default, but areas do not. This can be configured through Area properties).

great, but look at my minimal project:

https://github.com/beetbeet/godot-3-0-input-event.git

This project works fine in 3.0.6 (press play and click on object) but don’t works with 3.1 and i don’t know why :confused:

beetbeet | 2019-03-15 08:47

You need to set input_ray_pickable

input_ray_pickable = true

TyTYctA | 2019-03-16 14:16

thank you! it works! :slight_smile:

beetbeet | 2019-03-17 08:27