ive made a small game
where i have a enemy tank following a path
i can shoot it from my tank and it explodes when hit
my question is what kind of setup would i need for the enemy tank
which is following the path to fire back at me when it reaches a certain distance.
thanks
wayne
This could be pretty simple. As long as each AI tank can only target you, you can just calculate the distance between the tank and the target. Then, just set a conditional based on distance and you’re done. Example code:
if ((target.transform.position - transform.position).sqrMagnitude < range*range) {
shoot();
}
thanks for the answer, but dont i need some kind of gun prefab
set up for each enemy tank?
Im a little confused about how to set this up
thanks
wayne