How do I Change the animations?

Get help using Construct 2

Post » Mon May 11, 2015 1:42 pm

Hello everybody I'm having problems with the main character, basically I want to make that:
When - Left mouse clicked (gun) >> set animation to (player_gun)
But then:
When Key (S) is down (Player Crouch) >> set animation to (player_crouch)
But how do i make so when player has already picked up the gun before, then when he presses (S) then play animation (Player_crouch_gun).

And another problem is when I get stopped by the wall because the player is too big to go through and still holding button go left.... as soon as I press S to crouch it's teleporting him as he was walking with out stopping? So it moves him to the position like the player never stopped.

Thanks for attention!
B
8
S
3
Posts: 120
Reputation: 989

Post » Mon May 11, 2015 3:45 pm

Add subevents

When key S
-- player animation player_gun is playing
> set animation to Player_crouch_gun
--else
> set animation to Player_crouch

It might be even easier to give the player a boolean variable HoldingGun and check if that's true, especially if you are going to add more animations.

If I have to guess the second question has to do with your collision-polygon and maybe origin-point..
Check these or have the player's movement controlled by a square sprite with the animations pinned to it..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 11, 2015 5:41 pm

Thank you for replying! @LittleStain

I forgot to mention on how do you change Animations:

Playing ( Player Animation ) and when you pick up the gun how do you change them ?
- By destroying the Player Animation? or Making it invisible? while it's pinned to the Original Player or shade of the player?
Whats the best way ?

Because if I make it invisible it will not make the crouch (Player square) smaller? so he wont fit as the invisible square is there and not letting it go through small places where you need to crouch...

Or if for example I will have inventory in the future then if Item is selected play animation?

But...

Then how do you make that the animation does not stop the legs for 1 sec in between changing the items? Because when you keep changing the other Items it will keep changing the animation to start from beginning ? So it's going to have like a body glitch? I hope You got what I mean :) Ty for listening!
B
8
S
3
Posts: 120
Reputation: 989

Post » Mon May 11, 2015 5:47 pm

I have no clue what you mean..
Why should you destroy an animation?

Do you mean:

player on collision with gun
> player set animation to player_gun

You can set animation from current frame instead of beginning if the frames of the animations are the same.
If the animations are different you could first check the current animationframe and set the frame of the new animation to the corresponding one..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 11, 2015 7:01 pm

19 - Doesnt work :(
Image
B
8
S
3
Posts: 120
Reputation: 989

Post » Mon May 11, 2015 7:33 pm

19 shouldn't be a subevent of 18, but a seperate event.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 11, 2015 9:02 pm

Okey @LittleStain, But what if I set the Player(gun) Invisible and then Player(Crouch) Visible. The Collision Polygon will be not allowing to go through small holes as the player(crouch) Collision Polygon is smaller?
B
8
S
3
Posts: 120
Reputation: 989

Post » Mon May 11, 2015 9:35 pm

I'm not sure why you have different objects for the different animations..

I would use a seperate sprite for the movement, pin the player sprite to it and have all animations in the player sprite..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 11, 2015 9:51 pm

@LittleStain, I dont know how to explain better then that ...
Image

Image

And I changed the height of it... here:
Image

But, is this the best way to do it?

Thanks for attention!
B
8
S
3
Posts: 120
Reputation: 989

Post » Mon May 11, 2015 10:09 pm

It isn't the best way..
Those three sprites could just be 1 sprite with three animations..
All you'd have to do is set the animation instead of setting sprites invisible and settinging their height.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: MassimoF and 30 guests