Player Slows Down

adalpilscazaadalpilscaza Member Posts: 44
edited November -1 in Working with GS (Mac)
I am currently working on a game where the objective is for the character to eat (destroy) all of the blocks in a scene. To move, I make it so that when the person playing the game touches either to the right or left of the character, he will move to that location (X axis only, Y stays the same). After the character collides into one block, he immediately slows down, and will only return to his original speed once you release your finger and press down again. Obviously, this wouldn't make for very good gameplay, and am hoping that someone could help me out some more with this. Thanks.

Comments

  • giacomopoppigiacomopoppi Member, PRO Posts: 914
    Could you post a screenshot of the characters rules please so we can understand why it is slowing down? Why do you need to collide with the box if you have to destroy it?

    Giacomo
  • adalpilscazaadalpilscaza Member Posts: 44
    The reason I have a collide with the boxes is because the player is allowed to jump on top of them. To destroy them, I created a second actor called 'Eat', constraining its Y position to the Y position of the Character, and the X position to the Character's X, adding or subtracting 15 pixels so it is on the edge of the Character. This is so that when the 'Eat' actor touches the blocks, they are destroyed.

    I was planning on making a video showing my rules and behaviours, but after further looking at it I came up with a solution. I had an actor called 'Touch Me', which was the size of the whole screen. It recorded the touch X position. If it was greater than the player's X, I would change a boolean attribute called 'playerMoveRight' to true, and when released it changed to false. I did the same for Left, except instead of the touch being greater than the players X, it was less than.

    In the Character actor, I had - If playerMoveRight is true (the same for playerMoveLeft), Move To touch.position.X (for X position), self.Position.Y (for Y). I ran into problems with this, so I changed 'Move To' to 'Accelerate Toward', using the same X and Y coordinates. This worked well. When touch was released, I had 'Change Attribute self.motion.linearVelocity.X (or something like that) to 0. Accelerate toward seemed to work better and slow the player down less.

    However, if someone else had another solution for this, it would be greatly appreciated. Thanks.
Sign In or Register to comment.