how to add constant "drop" speed instead of gravity

381 Views Asked by At

I have a game where blocks drop from the top using a gravity animation, i.e. acceleration.

If I know want to change this speed to a constant speed.

How would I do that?

This would be my code to add gravity to a UIView which lets the object accellerate on it's way down. But what I want to achieve is to give it a constant speed or even a negative acceleration when it reaches the button of the screen. I would like to achieve somewhat a floating effect, like bubbles or ballons floating over the screen bouncing off off each other and finally resting on the floor. Compared with real physiks in real life this happens IMHO because the air is inhibiting the bubbles from falling right on the ground...

lazy var gravity: UIGravityBehavior = {
    var tempGravity = UIGravityBehavior()

    // everytime someone asks me for my gravity I'm gonna add it to my animator and this is onyl happend once
    tempGravity.magnitude = 0.3
    return tempGravity
}()
1

There are 1 best solutions below

0
On

It depends on what you have access to. If you can set the object's velocity - just make it a constant value in the "down" direction. otherwise you need to add a constant acceleration in the "up" direction so that no NET acceleration is occurring.

Happy to help with more info, but this is about as specific as I can be with the info provided.