private void OnCollisionEnter(Collision other) { var flag = other.gameObject.GetComponent <FlagController>(); if (flag == null) { return; } CameraController.i.Shake(); state = DozerState.Back; float backSpeed = 10f; Vector3 dir = -transform.forward; DOTween.To(() => backSpeed, (x) => backSpeed = x, 0, 0.7f) .SetEase(Ease.Linear) .OnUpdate(() => { rb.velocity = dir * backSpeed; transform.forward = -dir; }) .OnComplete(() => { state = DozerState.Control; }); flag.Defeat(transform.forward); }
public void AttackBound() { if (playerDozerController) { CameraController.i.Shake(); } state = DozerState.Back; float backSpeed = 15f; Vector3 dir = -transform.forward; DOTween.To(() => backSpeed, (x) => backSpeed = x, 0, 0.7f) .SetEase(Ease.Linear) .OnUpdate(() => { rb.velocity = dir * backSpeed; transform.forward = -dir; }) .OnComplete(() => { state = DozerState.Control; }); }
void Start() { state = DozerState.Control; }