imjp94 / gd-YAFSM

Yet Another Finite State Machine for godot
MIT License
534 stars 25 forks source link

Weird offset when clicking and dragging states #36

Closed joaopedrosgs closed 2 years ago

joaopedrosgs commented 2 years ago

Prerequisites

Expected Behavior

The state to be under the mouse when dragging

Current Behavior

It uses the offset of the last selected state If I left-click once, release the left click and then click again to drag, then everything works as expected

Errors in the editor

I don't really know if this is responsible or not, but these are the errors in my output panel

core/variant_op.cpp:1535 - Attempted set on a deleted object. res://addons/imjp94.yafsm/scenes/StateMachineEditor.gd:584 - Invalid set index 'selected' (on base: 'previously freed instance') with value of type 'bool'.

Video

https://user-images.githubusercontent.com/16986475/145796760-ee8e462b-fca8-4ae1-a06c-32a17fea757a.mp4

imjp94 commented 2 years ago

@joaopedrosgs, thanks for the detail bug report!

To be honest, this bug has been haunting me, but it was too random to reproduce. But somehow, I just figured it out that it can reproduced by these steps:

  1. Select a state in StateMachine graph
  2. Select any other node in scene tree
  3. Select StateMachinePlayer node again
  4. Weird offset occurs, whenever dragging state

Can you test if commit 01c5dcf9ac85396afcc9c2dbd7300c110b5105a5 fix the bug for you?

joaopedrosgs commented 2 years ago

Yes, the commit fixed the issue! Thank you =)