How do I let a object bounce

Get help using Construct 2

Post » Thu May 15, 2014 2:10 pm

Hy everybody,

I'am doing a platform game and I would like to know how let I bounce a object with platform behavior when it is landing. Like a ball fall on the floor and bounce until it will stay on the floor. I tried with on collision but it isn't working. Any idea?

Thanks
B
5
Posts: 18
Reputation: 263

Post » Thu May 15, 2014 2:21 pm

Take a look at this tutorial:

https://www.scirra.com/tutorials/787/create-your-own-christmas-game

I think it contains what you need.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Fri May 16, 2014 8:15 am

Hello TheDom, thanks for your post. I downloaded the project you posted and I learned some new features. The bullet behavior has the option to bounce off solids but unfortunately it doesn't work in combination with the platform behavior.

An object with platform behavior has no speed on landed. So I decided to place an invisible object 3 pixels before the solid. When the ball is falling and collide with the invisible object I multiply the VectorY with 0.5 the ball bounce off until it stay still on the solid ground. There is one problem. Sometimes it work, sometimes not. I think because the system detect the collision too late and the ball has no speed at all to multiply when it touch the solid ground.

How can I add just a bounce off behavior to the platform behavior?
B
5
Posts: 18
Reputation: 263

Post » Fri May 16, 2014 9:16 am

What about:
You create a Global Number Variable called JumpVariable
then
On platform jump:
set JumpVariable = 0

On platform land:
- if JumpVariable = 0 set PlatformGravity to 10 for exemple & simulate jump & add + 1 to JumpVariable
- if JumpVariable = 1 set PlatformGravity to 30 & simulate jump & add + 1 to JumpVariable
- if JumpVariable = 2 set PlatformGravity to 50 & simulate jump & add + 1 to JumpVariable
- if JumpVariable = 3 set PlatformGravity to Normal gravity & set JumpVariable to 0

That way you simulate a bounce and you are able to define how many times it will bounce and can even set random values for gravity each time your object jumps.
B
17
S
3
G
3
Posts: 89
Reputation: 2,825

Post » Fri May 16, 2014 9:59 am

Hey Telyko,

I like your idea and I'll try it out. But its random or the ball will always bounce the same way no matter if the ball is slow or fast. I want that the ball reflect the speed with 0.7 that the ball will stop after a while. Don't you have another brilliant idea? If I find an idea I will let you know.
B
5
Posts: 18
Reputation: 263

Post » Fri May 16, 2014 12:01 pm

I'm looking for a platformer project I have where the player bounced when he jumped on certain objects. I don't remember how I accomplished it but I'm sure I had more than behavior. In the meantime, try adding a the physics behavior in combination with platform behavior. I'll try to get back to you with it.
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Fri May 16, 2014 12:09 pm

You could add another Variable called BallSpeed on ball movement start
Set BallSpeed to 1 if speed between 1 and 30, set BallSpeed to 2 if speed between 30 and 60, etc..

and change the Platform Gravity each time each bounce to : BallSpeed x 1 for 1st bounce, Set Platform Gravity to : BallSpeed X 2 for 2nd bounce, etc...
B
17
S
3
G
3
Posts: 89
Reputation: 2,825


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests