How do I make a player hurt

Get help using Construct 2

Post » Fri Aug 28, 2015 9:23 am

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.
B
4
Posts: 19
Reputation: 238

Post » Fri Aug 28, 2015 9:35 am

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.
B
10
S
2
G
1
Posts: 51
Reputation: 761

Post » Fri Aug 28, 2015 9:50 am

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
B
49
S
9
G
4
Posts: 426
Reputation: 7,041

Post » Fri Aug 28, 2015 9:58 am

@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.
B
4
Posts: 19
Reputation: 238

Post » Fri Aug 28, 2015 11:14 am

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.
B
10
S
2
G
1
Posts: 51
Reputation: 761

Post » Fri Aug 28, 2015 11:50 am

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.
B
49
S
9
G
4
Posts: 426
Reputation: 7,041

Post » Fri Aug 28, 2015 12:22 pm

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?
B
4
Posts: 19
Reputation: 238


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 50 guests