How can I make a ball with physics slow down faster?

  • Hello!

    I have a ball that I can't control. I want it to stop after it moves, but sometimes it just moves really slowly so it takes long time for the x velocity to go to 0.

    How can I slow it down faster and faster the more time passes, but at the same time when it moves again next time, it has the same options as before it first moved? Like a golf ball on each shot.

    Thanks!

  • You can try increasing Linear Damping, Angular Damping, Friction settings.

    Also, you can add an event like this:

    if abs(Ball.Physics.VelocityX)<50 then Ball set Velocity X to (Ball.Physics.VelocityX*0.90)

    Just make sure this event is activated only when it's time to slow down the ball (after it hit the ground for example).

  • I did the first things except the code and it works better now, thanks! Tried the code and it was creating some physics problems. I found a solution to just be able to jump before 0 and works great.

    My only problem is that I don't know how to make the ball to not jump while mid air. Since this isn't platformer but physics, it doesn't do that automatically so it has infinite jump, and I only want one. I found solution like the image and it works great, but found out that at the tiny window of 0 to 20 while mid air, if you press the jump button it will jump.

    I tried many different things combined with touching ground too and this is the best solution so far with this small problem. Tried to isolate the Velocity X only but didn't work. I don't really know what to do anymore after I tried many things and my head is hurting a lot haha

  • You can simply put this event into a group and deactivate this group after the ball is launched. Re-activate the group again when needed.

    Or add a variable CanJump=1. Modify the event like this:

    On Space Pressed
    CanJump=1 
    		Ball Apply impulse...
    		Set CanJump=0
    

    Reset CanJump to 1 when it's ok to launch the ball again.

    .

    Also, if you need to test only X velocity, use System Compare Two Values event, with expression Ball.Physics.VelocityX

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I fixed all my problems, thank you!

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