0 Favourites

How do I make a player hurt

  • Hi,

    i would like to ask you guys on how do i make a player hurt like if the hero is on collision with an object aside from triggering the "Hurt" animation, it would like simulate jumping backwards. I have tried setting the vector Y and it is good but it only "Jumps" on the same place. I tried setting the vector X but nothing happens.

    Thanks.

  • I would disable player control for the hero for a period of time, and use "simulate control" for a jump with the correct direction. You can even set the platform behaviour properties up, like smaller jump.

  • Right:

    on collision >change player animation to hurt and set vector x and set vector y AND start ignoring player controls.. Also, make the player temporarily immune to new collisions with enemies and dangers

    upon animation hurt finished> no longer ignore player controls, restore animations to normal.

    I use a variable I call "stuck in move" and set it to 1 whenver the player is currently in an animation that ignores control until its done, like hurt and most attacks. When any of those animations finish, I restore the variable "stuck on move" to 0.

    This way, I can just check: Is "stuck in move" set to 0 when triggering standard animations and player input actions... so that the animations don't get over-ridden by default player control.

    I hope that makes sense.

    -Mike

  • Borgi: how can you simulate like "jumping back". Logic would be Jump+left but disabling the mirror.

    @Brashmonkey: I had tried that using vector Y. When my player is falling into an object with collision condition it will "bounce" on contact which is great but i used also vector x to simulate jumping away from the object to simulate "hurt" but vector X is not working.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • You can make a variable which is for example 0 when the player can control the hero, and 1 when the hero is hurting (lets call it HERO_STATE). Like a very basic state machine. And an other variable will also be good to detect which direction should the hero "hurt" (HERO_DIRECTION). So, I would make it like something like this:

    • HERO_STATE = 0

    -- enable Hero player input

    + add standard movement events here as subevents

    • HERO_STATE = 1 and HERO_DIRECTION = 0

    -- hero -> move left

    -- wait x

    -- set HERO_STATE = 0

    • HERO_STATE = 1 and HERO_DIRECTION = 1

    -- hero -> move right

    -- wait x

    -- set HERO_STATE = 0

    • on hero collision with enemy

    -- set HERO_STATE = 1

    -- disable Hero player input

    -- hero -> jump

    -- set HERO_DIRECTION = Hero.X < Enemy.X ? 1 : 0

    You also should handle when they are at the same position, or let it be like this.

  • Vector X will work if you:

    1) Don't have normal player controls active while the hurt animation is playing

    2) Don't have the deceleration turned up so high that the character's x velocity will go to zero instantly immediately after your action sets it to a number.

    BUT, If you want an easier way to do it:

    every tick>IF animation hurt is playing,

    sub condition>AND player character is facing left, then simulate player pressing right

    sub condition>AND player character is facing right, then simulate player pressing left

    This will ensure x movement in the right direction for the duration of the animation.

    cheers.

  • Thanks from both of you. I will try that one when my laptop is free because as of the moment someone is using my laptop. Construct 2 dont run in ipad...

    And one more thing. Since platformer player have scroll behavior, how can i zoom out when a player reaches a certain place on the game?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,489
DMT2005's avatar
DMT2005
Unread hot topic
0 Favourites
[plugin] Youtube player
175 20,538
rexrainbow's avatar
rexrainbow
Unread sticky
1 Favourites
C2 Games made with CocoonIO
136 89,815
minhcuong's avatar
minhcuong