I can’t get the AI to shoot at the correct range which is referenced from another script called RifleAI.
Well it works almost perfect if I type in a number but not if I put in the float range.
Let me explain in Code:
// This is where the range is referenced from aka the rifle script.
private Rifle weaponRifleScript;
void Update(){
if(canShoot == true){
Shooting();
}else{
canShoot = false;
}
}
void Shooting(){
targetDistance = Vector3.Distance(player.position, target.position);
// this is where it gets the range from the rifle script.
float range = weaponRifleScript.range;
if(targetDistance < range){
weaponRifleScript.InvokingRepeating("Shoot", 0.5f, 20);
}
}
So yeah, its simply not working, either it shoots from what ever range or does not shoot at all.
Heeeelp…