How do I let a object bounce

0 favourites
  • 7 posts
From the Asset Store
Who wants to be a Millionaire Clone. An educational coding source
  • 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

  • Take a look at this tutorial:

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

    I think it contains what you need.

  • 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?

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)