void Update() { float elapsedSec = Time.time - lastTime; lastTime = Time.time; secondsSinceLastScan += elapsedSec; if (isForPlayerShip) { return; } if (targettedAst != null) { turret.SetNewTarget(targettedAst.transform.position); } if (secondsSinceLastScan >= secondsTillScan) { if (miningMode) { if (targettedAst != null) { //turret.SetNewTarget(targettedAst.transform.position); if (turret.GetAngleToTarget() < 7) { targettedAst.InflictDamage(dmgPerSec * elapsedSec); if (isFiring == false) { StartFire(); } else if (isFiring == true && targettedAst.currHealth <= 0) { // send resource to owning space station owner.gold += 5; targettedAst = null; StopFire(); } } } else { CheckForAsteroids(); } } else { if (targettedBot != null) { targettedBot.TakeDamage(1); // todoj if bot's health is <= 0 then send itemdestroyed operation. //if (targettedBot.c) } CheckForNearbyBots(); } } // CheckForTurn(); // CheckForFire(); }
void CheckForTurn() { // Construct a ray pointing from screen mouse position into world space Ray cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition); // Raycast if (Physics.Raycast(cameraRay, out hitInfo, 500f)) { turret.SetNewTarget(hitInfo.point); } }