playMaker

Author Topic: [SOLVED] 2D Game - Movement gets stuck  (Read 3921 times)

Erzberger

  • Playmaker Newbie
  • *
  • Posts: 5
[SOLVED] 2D Game - Movement gets stuck
« on: March 22, 2015, 02:24:04 PM »
Hi there,

I have an android breakout-like game and set up the movement of the paddle by creating two big boxes (left screen & right screen) and giving them "Touch Object Event 2D" Actions. "Begin Touch" sends the FSM into the next state, which does a "translate" or "set velocity" (I tried both) of the paddle. "Touch Ended" & "Touch cancelled" sends the FSM back into the first state.

Here´s the problem: Sometimes the game does not seem to recognize when I have lifted my finger and does not revert to the first state. Ergo the player keeps moving despite me not touching the screen.

I´d be grateful for any pointers. I have just started out doing game development 2 months ago...
« Last Edit: April 09, 2015, 03:12:18 PM by Erzberger »

MU65

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 2D Game - Movement gets stuck
« Reply #1 on: April 06, 2015, 06:27:06 PM »
Hi,

I had a similar problem but not with a touch action, it was with a game pad control...I fixed it by dividing in two FSM, one listening for the move of the joystick and the other for the absence of movement.

Maybe this could help you...

Have a nice day Playmakering

Erzberger

  • Playmaker Newbie
  • *
  • Posts: 5
Re: 2D Game - Movement gets stuck
« Reply #2 on: April 09, 2015, 03:11:21 PM »
Thanks, MU65! This got me thinking in the right direction. So for anyone interested or people who might encounter a similar problem, I´ll post my solution here:

I attached an FSM to the object I want to move (my paddle) and gave the action to move my player along the x axis by a global float "PlayerMovement".

Then I made a touch on the left set the float value of "PlayerMovement" to -3 and and a touch on the right screen box to 3.
Then I created children of the two screen boxes and gave them the task to set the float to 0, if they perceive the ending or cancellation of the touch (I used "touch event" for this instead of "touch object event 2d" because that way it doesn´t matter where my finger is when I lifted it).

Phew, this was a tough on (for a newbie like me :-P).

Thanks again, MU65, for priming my pump. I´ve been stuck for a while...