I have a game I'm building in Unity with some objects orbiting a sphere via rotating around a pivot point (0,0,0) at a radius of 10 units on the z-axis. The orbiting objects all have the same velocity. This all works great, but now I need to add a bouncing effect when they run into each other so they start orbiting in a new direction when colliding.
I am currently detecting a collision between two orbiting objects, and trying to determine the resulting reflection vector of the collision. The orbiting objects all have sphere colliders on them.
Here is a relevant code example for how I am orbiting the objects:
var velocity = 15f;
var directionVector = new Vector2(Random.Range(-1f, 1f) * velocity, Random.Range(-1f, 1f) * velocity);
transform.Rotate(directionVector.y * Time.deltaTime, -directionVector.x * Time.deltaTime, 0.0f);
Here is how I am currently trying to reflect the collision on the
var bounceVector = Vector3.Reflect(transform.forward, collider.gameObject.transform.forward).normalized;
directionVector.x = bounceVector.x * velocity;
directionVector.y = bounceVector.y * velocity;
This does cause the objects to "bounce" off of each other, but the bounce direction doesn't seem right, so I have something screwed up. I also feel like this probably doesn't even matter that it's on a sphere because all I need to do is take two direction vectors and find their resulting reflection vector on a collision. Any thoughts?