Why do I have to press 10 times a button for KinematicBody2D to react?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Qws
:warning: Old Version Published before Godot 3 was released.
extends KinematicBody2D

func _ready():
	set_process_input(true)
	pass
func _input(event):
	if event.type != InputEvent.KEY: return
	
	if event.scancode == KEY_RIGHT and event.is_pressed():
		move(Vector2(10,0))
		print("moving to Right")
		pass
	if event.scancode == KEY_LEFT and event.is_pressed():
		move(Vector2(-10,0))
		print("Moving to Left")
		pass
	if event.scancode == KEY_UP and event.is_pressed():
		move(Vector2(0,-10))
		pass
	if event.scancode == KEY_DOWN and event.is_pressed():
		move(Vector2(0,10))
		pass

It’s a child of a Camera Node, and I need to press 10 times left, right ,up or down key to activate. I see nothing in code that says that…?

does it print Moving To … each time you press the button?

keikochan2k1 | 2017-01-30 16:23

Yep… It does says “Moving to…” but it doesn’t move till I pressed it 10 times…

Qws | 2017-01-30 17:15

Do you have anything else running in your scene? Other scripts?
Is it always exactly 10 times or is it random?

Zylann | 2017-01-30 17:20

@Zylann I solved the issue by disabling the drag margin, this caused the camera to not react till I’ve made several steps, which was 10. It seems like it’s fixed on 10, but I guess you can alter it.

Qws | 2017-01-30 17:35

Ah, it’s clear when seeing your scene… that’s a really unfortunate specific case you fell in^^

Zylann | 2017-01-30 18:02

:bust_in_silhouette: Reply From: Qws

I’ve solved the issue by turning off these options:

H Enabled
V Enabled

Drag Margin

Those options are for 2D RPG camera view. I founded it out by adding a 2D sprite. I didn’t need the Drag Margin… so if anyone had the same issue…

Just disable the Drag Margin.