void Returning() { if (state == TankSate.Return) { if (timerReturnTime < returnTime) { float ratio = timerReturnTime / returnTime; transform.position = Vector3.Lerp(destination, startPosition, ratio); timerReturnTime += Time.deltaTime; } else { transform.position = startPosition; state = TankSate.Stay; } } }
void Going() { if (state == TankSate.Go) { if (timerGoDelay > 0) { timerGoDelay -= Time.deltaTime; } else { distanceTraveled += speed * Time.deltaTime; float ratio = distanceTraveled / distanceToGo; //transform.position = localForwardVector * distanceTraveled; transform.position = Vector3.Lerp(startPosition, destination, ratio); if (distanceTraveled >= distanceToGo) { transform.position = destination; state = TankSate.Return; timerReturnTime = 0; } } } }
public void PlayerDetected() { state = TankSate.Go; timerGoDelay = goDelay; distanceTraveled = 0; }