Problem when actor collides

Hi,

Im developing a game where the Hero actor moves to the position where the mouse touches on screen. I record every touched position in a table and the next time the mouse touches any other position on screen, I rewrite the table and make my Hero actor move to the new position. And this is working fine. Along the path the Hero moves, I have obstacles such as stones. I do not want my Hero to walk through it. I have the collide function to not allow the Hero to go through. But my Hero happens to be sliding up or downwards until he reaches the end of the screen when he collides with those stones.

I believe this is because the Hero is trying to move towards the touched position, and since he has collide with an obstacle, he is not able to reach that point and therefore he is sliding.

Is there a way for me to get my Hero move towards the touched position after he has move out of the obstacle he collided? in another word is to stop sliding and move to the position the mouse touched?

Thanks in advance.

Comments

  • forthebirdsforthebirds Member, PRO Posts: 16
    Perhaps you should try the accelerate toward behavior. (Just a guess.)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Part of the answer is to set a boolean to true when the actor collides with an obstacle and then set the move rule to only trigger when that boolean is false. You then have to decide how to -- if you need to -- get the player moving again by changing the boolean value after some amount of time and possibly moving the character away from the obstacle slightly to be sure the collision doesn't happened immediately again to stop the player's movement.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ganeshjiwa51ganeshjiwa51 Member Posts: 12
    Thanks forthebirds and tatiang for your reply.

    tatiang, i will try it out. thanks man
Sign In or Register to comment.