public void UpdateVelocity(object[] data) { var horizontalMovement = (float)data[0]; if (Mathf.Abs(horizontalMovement) <= deadZone) { return; } if (boundsController && keepInBounds) { if (boundsController.IsOutOfBounds(horizontalMovement < 0)) { return; } } velocity = Vector3.right * (horizontalMovement * speed * Time.deltaTime); if (!prone) { transform.position += velocity; } if (Mathf.Abs(horizontalMovement) > 0) { ChangeDirection(horizontalMovement > 0 ? 1 : -1); } }
IEnumerator KeepMoving(Vector3 right) { var velocity = right * speed * Time.deltaTime; while (true) { transform.localPosition += velocity; if (bound.IsOutOfBounds(right.x < 0)) { StartCoroutine(DisableAfterTime()); break; } yield return(null); } }