Character bounces once upon landing?

Get help using Construct 2

Post » Sat Jan 31, 2015 7:15 pm

I love it on Mario when he lands, and he does a little bounce just once as he collides with the ground. Is there a really easy way of doing this? I'm moving over from MMF, and usually you'd have to test flags or alt values for the character being airborne and flagging on and off so the bounce occurs once per fall. I'm using the default platform engine if this helps :D Thanks!
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,282

Post » Sun Feb 01, 2015 1:37 am

Create a global Variable called Bounce.
Create 2 sets of conditions.

1st)
Player > On Landed >
........ (sub event) System > Bounce =1 > Set Bounce to 0
.......... Else...........System > Bounce =0 > Set Bounce to 1

2nd)(dual conditions)
Player > On Landed > Set Platform Vector Y -600
System > Bounce =1
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,293

Post » Sun Feb 01, 2015 5:57 pm

Hi there, thanks for the help so far, I have tried this but the character keeps continually bouncing and doesn't stop :/ Did I put this in correctly? :D
You do not have the required permissions to view the files attached to this post.
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,282

Post » Sun Feb 01, 2015 7:03 pm

Event 44 is unnecessarily complicating things. Remove it and set the object's Y vector in event 42 instead and you should be golden.

On a side note, you should have an event that sets bounce back to 0 upon jump. If you don't do this, your bounce state can get messed up if the player jumps right as they're first hitting the ground.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Sun Feb 01, 2015 8:02 pm

Platform on landed
ACTION ----> Set Bounce to 1 - Bounce
-sub-event: Bounce = 1
ACTION ----> Set Vector Y to -600
ACTION ----> Set Bounce to 0
-sub-event: Bounce = 0
ACTION ----> Set Bounce to 1
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Feb 01, 2015 8:31 pm

Thank you all, this seems to work! Just out of interest, what is Set Bounce to 1 - Bounce doing? I'm having fun with the subevents, something MMF never entertained possibilities of (not to mention proper Else operators!!)
You do not have the required permissions to view the files attached to this post.
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,282

Post » Mon Feb 02, 2015 5:04 am

Here's a screen shot of how I employed it

Image
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,293

Post » Mon Feb 02, 2015 5:32 am

@Zebbi
the 2 sub-events should be same level.

like this:

Platform on landed
ACTION ----> Set Bounce to 1 - Bounce
--------sub-event: Bounce = 1
--------ACTION ----> Set Vector Y to -600
--------ACTION ----> Set Bounce to 0
--------sub-event: Bounce = 0 (same level as sub-event above)
--------ACTION ----> Set Bounce to 1

technically, the way you do it in your screenshot is working only because you have the "set Bounce to 0" action before the sub-event with condition "Bounce = 0". Codes are read top to bottom.

Just read the conditions from top to bottom, first check if landed, then Bounce = 1, then if Bounce = 0 ? The last 2 conditions are not possible to be true at the same time. So yeah the 2 sub-events should be same level

if Bounce = 1,
Bounce = 1 - Bounce
Bounce = 1 - 1
Bounce = 0

if Bounce = 0
Bounce = 1 - Bounce
Bounce = 1 - 0
Bounce = 1

Let's just say you chose to use values that aren't 0 and 1, then you can't use that 1-Bounce expression/formula

Quickly edited your screenshot here to match what I was saying
You do not have the required permissions to view the files attached to this post.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Feb 02, 2015 6:01 am

Yes, a little cleaner but the result is identical.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,293


Return to How do I....?

Who is online

Users browsing this forum: donstathemonsta and 25 guests