Godot runtime bug?

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

I’m very new to the engine and encountered something that I don’t think is normal. I did this very small bit of code.

var activationKeyReleased : bool = false

func _physics_process(delta):
func fall_down(delta):
	if activationKeyReleased == true:
		self.rotation_degrees += 70 * delta
		if self.rotation_degrees >=90: 
			activationKeyReleased = false 

func _input(ev):
	if Input.is_key_pressed(KEY_SPACE) and ev.echo == true: 
		self.scale.y += 0.15
	elif ev.is_action_released("ACTIVATEINCREASE"):
		activationKeyReleased = true

I get the message in the debugger "Invalid get index ‘echo’ (on base: ‘InputEventMouseMotion’)
Sometimes it works and sometimes it doesn’t when I run the code. When I exported it, it worked fine everytime thought. Maybe its to do with mouse movement but I don’t know why.

I fixed it, figured out _input(ev) detects all inputs which include mouse movement, so if I’m holding space and moving the mouse thats new input and mouse movement is not .echo I don’t think.

func _input(ev):
	if Input.is_key_pressed(KEY_SPACE) and ev is InputEventKey: 
		if ev.echo == true:
			self.scale.y += 0.15
:bust_in_silhouette: Reply From: Zylann

Yes, _input receives all kinds of events, and using Input is not really the expected way to use this function. Take a read of all this article: Input examples — Godot Engine (3.1) documentation in English

is_echo() is specific to keyboard inputs (related to key repeats when you hold a key for more than 1 second), so you should check if ev is a keyboard event before calling it. In your first code, you were not doing that.