playMaker

Author Topic: 2d Collision Event Problems  (Read 1407 times)

AlexK

  • Playmaker Newbie
  • *
  • Posts: 2
2d Collision Event Problems
« on: August 03, 2016, 12:42:56 AM »
Hi,

I'm new to Playmaker, and I have a problem with 2D movement. I have a square that I want to move only one direction at a time when I tap a key: up, down, left, or right, until it hits a block. Then the player can move in a new direction after a collision at a block. As it's moving, I don't want the player to be able to change direction. In each movement state, I finish the state using a Collision 2D Event. I've tried On Collision Enter 2D at first, but if I collide with a wall and move in the direction of the wall again, the movement State doesn't exit, and the player is frozen.

So instead, the Collision event I'm using to exit the movement states is On Collision Stay 2D. It gets rid of the problem of being stuck and not being able to move. But it causes a new problem. Once I hit a block, I can't move in an adjacent direction, because sliding against the block causes my square to stop moving. I have to tap the key several times to get free from the block. There is a link to a video of what's happening. And there are screenshots of the main Check For Movement state and the Move Right State.

Any ideas of what I can do to fix this? Thanks in advance for even reading this.

Video of issue:

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: 2d Collision Event Problems
« Reply #1 on: August 03, 2016, 09:58:58 AM »
I think i know how to fix it, i'll answer from home  :)

You definitely need to use on collision enter and make a workaround so if you move in the direction of the wall again it doesn't get stuck.

Quite a challenge, can you send me the project to try something out? :D
« Last Edit: August 03, 2016, 12:24:27 PM by krmko »
Available for Playmaker work

AlexK

  • Playmaker Newbie
  • *
  • Posts: 2
Re: 2d Collision Event Problems
« Reply #2 on: August 04, 2016, 09:35:51 AM »
Hi krmko,

Thanks for the reply! I'll send a PM to you with a link to my project soon. I just have to get it uploaded.