How to use "get_relative" in an "InputEventScreenDrag"?

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

For dragging a sprite I want to use “get_relative()” of an InputEventScreenDrag, but value is always (0, 0). This should be “Drag position relative to its start position”.
For now I use “InputEventScreenDrag.get_position” for positioning a sprite, something like:

newPosition = event.get_position
translate(newPosition - oldPosition)
oldPosition = newPosition

it works, but I tried:

translate(event.get_relative())

as it seems much more elegant, but this doesn’t work. What’s my error here?

:bust_in_silhouette: Reply From: s0ra

I was also working on similar stuffs. Looking to the documents for Godot Engine, it states that this class only available on mobile devices.

But don’t worry. You can actually emulate touchscreen on your desktop build. Your problem can appear if you don’t get this setting on.

  • For Godot 3.0
    Project > Project Settings > Display > Window
    Project Settings

Thanks for answer. Was not aware of “Emulate Touchscreen” - will give this a try today.

Maxpilot | 2018-03-12 08:04