Godot Version
v4.3.stable.mono.official [77dcf97d8]
Question
Hello, I want to extend a custom InputEvent from InputEventMouseMotion so I can have a rotation variable that controls the rotation of the cursor (a sprite replace the cursor). So I have the follow class:
# inputEventRemoteMotion.gd
class_name InputEventRemoteMotion extends InputEventMouseMotion
var rotation: float = 0.0
Then in one of my other script I can emit this custom event by
var motion = InputEventRemoteMotion.new()
motion.position = Vector2(x, y)
motion.rotation = 45
print(motion is InputEventRemoteMotion) # this print true
Input.parse_input_event(motion)
However in my another script handles this event:
const InputEventRemoteMotion = preload("res://scripts/inputEventRemoteMotion.gd")
...
func _input(event: InputEvent) -> void:
if event is InputEventRemoteMotion:
print("InputEventRemoteMotion")
elif event is InputEventMouseMotion:
print("InputEventMouseMotion")
The “InputEventRemoteMotion” is never printed but “InputEventMouseMotion” is always printed, how can I check if the event is “InputEventRemoteMotion” in this case? Thanks.