playMaker

Author Topic: Constant Movement then Cancel it.  (Read 2704 times)

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
Constant Movement then Cancel it.
« on: September 01, 2014, 04:48:32 PM »

I want when i press right and release the object keeps moving right, and when i press left and release the object starts moving left, I understand that checking "every frame" & "per second" keeps it moving, but the movement doesn't get canceled when i use the opposite direction. Tried using booleans but failed for some reason.
So, how to achieve that ?  PS: i will be using touch event.

Phuzz

  • Full Member
  • ***
  • Posts: 101
    • Bzilla Games
Re: Constant Movement then Cancel it.
« Reply #1 on: September 02, 2014, 02:22:59 AM »
Hello,

Maybe this would work:

Lets say you have a character you want to move left and right based on (A) Left, (D) Right, Keys.

In the "Moving Right" state you can add the action of your choice to simulate the character right, at the same add the (Get Key Down (A) Left) so as soon as it is pressed it sends an event to the "Moving Left" state while stopping the Action moving your character to the right, then do the opposite for the "Moving Left" State.

Edit: I just noticed that you use touch event, You can apply the same technique but insteadd apply touch events, If Touch.X is Greater than Character, send Moving Right, if Less than, Move left.

I have attached a rough image, hope this helps.

Keep in Mind that "Every Frame" is expensive to the CPU and only use it when there is no other way. Im no pro but these are my techniques.

« Last Edit: September 02, 2014, 02:25:21 AM by Phuzz »
Bzilla Games "Education with a Tickle!"
Qbucket Games "Voxel Games"

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Constant Movement then Cancel it.
« Reply #2 on: September 02, 2014, 08:16:01 PM »
Thank You, that really helped.  :)

Phuzz

  • Full Member
  • ***
  • Posts: 101
    • Bzilla Games
Re: Constant Movement then Cancel it.
« Reply #3 on: September 03, 2014, 03:13:56 AM »
 :) Glad it worked
Bzilla Games "Education with a Tickle!"
Qbucket Games "Voxel Games"

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Constant Movement then Cancel it.
« Reply #4 on: September 03, 2014, 04:49:44 AM »
Yes everything works fine, but there is a Glitch !

Whenever i tap with two fingers at the same time, the object just stops moving, and stops recognising anymore taps.
How to fix this ?!

Phuzz

  • Full Member
  • ***
  • Posts: 101
    • Bzilla Games
Re: Constant Movement then Cancel it.
« Reply #5 on: September 03, 2014, 05:47:23 AM »
If you dont need the option to use two fingers at a time maybe you can disable multitouch? Though I havent tried how this is done.
Bzilla Games "Education with a Tickle!"
Qbucket Games "Voxel Games"

Abdou23

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Constant Movement then Cancel it.
« Reply #6 on: September 03, 2014, 03:10:32 PM »
If you dont need the option to use two fingers at a time maybe you can disable multitouch? Though I havent tried how this is done.

I'm not using any form of multi-touch. but i'm using the exact setup from the post above.

Phuzz

  • Full Member
  • ***
  • Posts: 101
    • Bzilla Games
Re: Constant Movement then Cancel it.
« Reply #7 on: September 04, 2014, 05:09:05 AM »
I honestly do not have a solution right now im sure its simple though if i figure it out you will find it posted here.
Bzilla Games "Education with a Tickle!"
Qbucket Games "Voxel Games"