Calculate a new position instead of using Vector3.back

I am writing a simple avoidance function.
Spheres (enemies) target and move towards a capsule (player) to hinder its movement. When a sphere hits the capsule I instruct it to jump back in its own local space, after which it resumes moving towards the enemy again:

After the jump I check whether its new position might overlap with another enemy, if so, I move that enemy backwards in it’s local space as well.
Now instead of translating multiple enemies I’d prefer to calculate an enemy’s new position to see if it interferes with another enemy position.

The trouble I have is that the enemy has it’s own local rotation and I do not know how to calculate its new position after a vector3.back translation that takes in account its local rotation (or maybe direction, actually).
I simply do not know and cannot find the math to accomplish this.

So ehm,… Help?
Thanks in advance!


transform.forward gives you the object’s direction in world space. You can use -transform.forward for the reverse direction.

That said, is there a reason you don’t just use the built-in physics? That should be able to resolve this sort of thing.