0 votes

The preview is around -70, 20 away from the actual mouse pointer, I have searched and searched for an answer to this, found nothing so far. If i read the function right it returns the mouse pointer position? Is there somewhere I can check the mouse position while the app is running? Or something else to check?

This is for an inventory system, and if I drag the item and drop on a new slot that works fine, so it seem to be getting the proper mouse position, just the preview is so far away.

Thanks

 func get_drag_data(_pos):
    if slot.item_struct != null:
        var preview = TextureRect.new()
        preview.texture = slot.item_struct.i_image
        preview.expand = true
        preview.rect_size = Vector2(24, 24)
        preview.add_child(preview)
        set_drag_preview(preview)
        return slot
Godot version 3.2.2
in Engine by (17 points)

1 Answer

0 votes

The Node given as preview can have children. You could Set a basic Node2D as preview, with your TextureRect as child. The advantage is that you can set the position of the child relative to it's parent, to counteract the offset you where experiencing.

by (2,092 points)

Will give that a try, thanks

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.

Categories