# How to make a sphere bounce while it is moving forwards Unity

I am trying to make a sphere that I have moving forwards also bounce at the same time. Here is what I have tried.

Adding a physic material to the sphere and setting the material with a friction combine of minimum, setting the bounce combine to the maximum.

Setting the collision detection on the rigidbody of the sphere to continuous.

After trying all of this, it all resulted in when the sphere hits the other gameobject just sitting there and moving forwards without bouncing. Here is the code that I have for moving the sphere.

public float forceMulti = 50f;

private Rigidbody rb;

private void Awake()
{
rb = GetComponent<Rigidbody>();
}

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
rb.velocity = transform.forward * Time.deltaTime * forceMulti;
}


If there is a way to make the sphere bounce through code while it is moving forwards that would be great and I would really appreciate the suggestions.

Thanks.

• You are setting the velocity every frame in Update. So any vertical bouncing movement it might have wanted to do, you're deliberately overriding and telling it "no, DO NOT bounce, just move forward and only forward instead". Jun 30 '19 at 20:11
• The suggested answer below has brought back the jumping on the sphere. The problem now is that over time the height of the jump, as well as the speed of the sphere, increases over time. Is there a way to keep both of those constant? Thanks! Jul 1 '19 at 0:06

• You should only need to call AddForce once. Think of it as giving the sphere a push - when you replaced the line, you're now pushing the sphere once each frame, increasing the speed over time. Try moving the AddForce line into Start. Jul 1 '19 at 5:16