A quick FYI, the Debug.Log function will automatically do a “ToString()” on objects you pass in.
So the vector that subtraction gives you can be imagined as an arrow pointing from “other” to “transform”. The length of that vector is equal to the distance between them. When you “normalize” it, it shrinks the arrow down until it has a length of 1 but it still points the same way. That’s what is commonly called a “direction”, a normalized vector or “unit vector” can be used as a direction.
Generally speaking, you would multiply a direction by a distance.
For example, here is how you can move something 10 units in a direction:
Vector3 direction = Vector3.right; // is already normalized, and is the same as 'new Vector3(1,0,0)'
Vector3 distance = 10;
Vector3 changeInPosition = direction * distance; // equals (10,0,0)
transform.position += changeInPosition;
So one way to get this bounce to happen is to have each object get the direction from the other one to themselves, and set their velocity going in that direction.
Keep in mind that Triggers are generally not used for blocking collisions like this, but without changing that, this could potentially work:
Rigidbody rb; // get component in Awake or Start, etc.
private void OnTriggerEnter(Collider other) {
Vector3 direction = (transform.position - other.transform.position).normalized;
// get our current speed
float speed = rb.velocity.magnitude; // magnitude is the length of the vector
// set velocity with the same speed, in the new direction
rb.velocity = direction * speed;
}
Assuming both objects have this function, and both objects get their respective OnTriggerEnter called (I would hope that is the case every time), this will send both objects away from eachother at the same speed they were going when they collided.