// Update is called once per frame void Update() { if (gc.isFinished) { transform.Rotate(0, 0, idleAngularSpeed * Time.deltaTime); _effectiveStretchFactor = Vector3.one; _rigidbody2D.velocity = Vector2.zero; return; } else if (!gc.IsActive()) { _rigidbody2D.velocity = Vector2.down * 0.01f; return; } if ((Input.GetButtonDown("Fire1") || Input.GetKeyDown(KeyCode.Space)) && !isSplit) { StartCoroutine(Split()); } var x = Input.GetAxis("Horizontal"); var y = Input.GetAxis("Vertical"); var movementDirection = Vector2.ClampMagnitude(new Vector2( Mathf.Abs(Mathf.Pow(x, controlSharpness)) * Mathf.Sign(x), Mathf.Abs(Mathf.Pow(y, controlSharpness)) * Mathf.Sign(y)), 1); _rigidbody2D.velocity = movementDirection * speed; if (_rotationTweener != null && _rotationTweener.IsActive()) { _rotationTweener.Kill(); } var magnitude = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).magnitude; gc.SetMovementAudio(magnitude); if (magnitude > 0.1f) { float angle = Mathf.Atan2(movementDirection.y, movementDirection.x) * Mathf.Rad2Deg - 90f; var rot = Quaternion.AngleAxis(angle, Vector3.forward); var vec3End = new Vector3(rot.eulerAngles.x, rot.eulerAngles.y, rot.eulerAngles.z); _rotationTweener = transform.DORotate(vec3End, rotationDuration, RotateMode.Fast); //transform.rotation = rot; // if (_rotationTweener == null) // { //_rotationTweener = transform.DORotateQuaternion(rot, rotationDuration); // } // else // { // _rotationTweener = _rotationTweener.ChangeEndValue(rot, rotationDuration); // } _effectiveStretchFactor = stretchFactor; } else { // Idle if (!isSplit) { transform.Rotate(0, 0, idleAngularSpeed * Time.deltaTime); } _effectiveStretchFactor = Vector3.one; } }