0 votes

Hi there,

Maybe I'm not using InputEventScreenDrag properly, but it seems like the event's "relative" vector2 values are relative to the last frame position versus the start position as the documentation suggests.

My code is very simple:

func _unhandled_input(event):
     if event is InputEventScreenDrag and event.index == 0:
          touch_position = event.get_position()
          touch_vector = event.get_relative()
          touch_speed = event.get_speed()

I then have another block of code outputting the values every frame:

     if debug:
        debug_text.text = "" \
        + "TOUCH POSITION: " + str(touch_position) + "\n" \
        + "TOUCH VECTOR: " + str(touch_vector) + "\n" \
        + "TOUCH SPEED: " + str(touch_speed) + "\n" \

What's happening when I drag slowly is the touch vector magnitude is at 0.333... so my guess as to what's likely happening is it's constantly updating the 'start' position to be the position of my touch in the previous frame, versus being the overall start position of the drag/touch.

Am I doing something wrong here? Or misreading the documentation / misunderstanding how drag relative is supposed to work?

Reason I ask is this means I need extra code to record the first general touch and it's position, and then calculate the real relative drag vector magnitude.

Hopefully the above is clear.. any help is greatly appreciated!

Godot version 3.3.stable.official
in Engine by (53 points)

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.