After collision rotate and move

I have been trying to make a spawning object move around, make collision, then rotate and move an other direction again. My world has a ground, which has some level difference at some points en walls surrounding it. I have a empty GameObject that spawns a ball. I want the ball to keep moving around and bounce of walls once it makes collision.

The spawning, collision and rotation work fine. But I somehow can’t keep the prefab, which is a simple ball in my case and a rigidbody, to keep moving around the surface. The walls have a Boxcollider.

Can someone please help me? Struggling with this problem for some weeks now and it’s driving me crazy. :slight_smile: I have tried many many things and lost sight of it a bit.

Given the lack of information you’re supplying regarding ‘keep moving around the surface’, I suppose that your issue is related to a common difficulty, which is understanding the DIRECTION of movement.

Quite simply, I suspect that you might not be making the object turn the appropriate angle around the world y axis, once it hits an obstacle.

 - access the collision procedure
 - add a Debug.Log("I collided"); instruction to it
 - add the following to the same procedure
Quaternion newrotation = Random.rotation();
transform.rotation = newrotation;

In the case that the object actually does something resembling a random new direction, post how you calculate the new direction after bounce.