playMaker

Author Topic: Problem with drag object  (Read 865 times)

mooblegum

  • Playmaker Newbie
  • *
  • Posts: 18
Problem with drag object
« on: May 25, 2020, 06:03:21 AM »
Hi Everyone,
I am trying to fix a bug
I have a Game Object with a FSM that allow it to be dragged with finger touch or mouse.
It work fine, exept when the mouse or the finger move too fast. When I move the finger quickly the GO is reset to 0,0 (center of the screen) instead of following the finger.
The scene is very simple and my computer quite good, I dont think it come from a hardware problem...
Do you have an idea what could be causing the problem ?

Thank you :)

« Last Edit: May 25, 2020, 06:14:25 AM by mooblegum »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Problem with drag object
« Reply #1 on: May 25, 2020, 04:09:58 PM »
Hi.
for the Mouse Up and Touch ended you should not use 'Finished' Transition.

made dedicated event for it.
You can make 1 for each and set for example 2 empty states in between then add a breakpoint (right click a state header and enable breakpoint)

this will pause the game when it reaches that state, then you can be sure what action goes wrong.

Also you might want to store the finger id on touch began and on the other one set that id.

Are you testing with mouse or on a touch device (connected to unity)

mooblegum

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Problem with drag object
« Reply #2 on: May 26, 2020, 06:15:39 AM »
Thank you for the response djaydino :)
I did what you recommended but I didn't fix the problem, in fact the GO was resetting while the FSM stayed in the same state.
The problem was my box2D collision was a bit small, maybe unity did not track the finger when I was dragging the object too fast. By making the collision bigger it fixed the bug.
Thanks for the advice, it will help me make cleaner FSM.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Problem with drag object
« Reply #3 on: May 26, 2020, 11:40:07 AM »
Hi.
It was actually not a fix, but to find the issue :)

breakpoints are very useful for debugging.

Also transitions are important not to use Finish for this type of actions :)