public void OnUpdate() { cooldown += Time.TimeMult; if (targeter.Target == null) { return; } //Getting the distance to target Vector3 thisPos = GameObj.Transform.Pos; Vector3 targetPos = targeter.Target.Transform.Pos; Vector3 distance; Vector3.Subtract(ref targetPos, ref thisPos, out distance); //Turning logic GameObj.Transform.TurnTo(distance.Xy.Angle); //Firing logic if (cooldown >= FiringDelay && distance.Length <= Range) { cooldown = 0; shot.Fire(); } }
protected void Fire() { shot.Fire(); ammoUsed++; if (ammoUsed >= AmmoCount) { Scene.RemoveObject(GameObj); } }