Making a tank battle game where there are 3 tanks per side on a 2D field and the player controls one tank while the others are controlled by AI. I’m just trying to make a simple AI where the tank detects if its near other tanks and moves away from them but am at a bit of a loss as to how to implement this. I’ve been toying with using Physics.OverlapSphere but I don’t how to tell in which the direction the object is when I’ve got the colliders.
Any ideas?
say you are computer tank AA
say one of the other tanks is called TT
directionToTT = TT.position - AA.position;
directionToTT = directionToTT.normalized;
now, you want to move in the other direction
directionIWantToMove = -1 * directionToTTl
So, you should move in that direction.
NB you do not have to use raycasting, spheres etc. Because, you simply know all the things in the scene. Just use those gameObjects.