void SpinnerMove() { if (Input.GetKey(AttackKey) && Energy > EnergyUse) { UseEnergy(); IsOn = true; if (SpinnerSpeed < SpinnerMaxSpeed) { SpinnerSpeed += SpinnerMaxSpeed / 60f; } else { SpinnerSpeed = SpinnerMaxSpeed; } } else { PlusEnergy(); IsOn = false; if (SpinnerSpeed > 0f) { SpinnerSpeed -= SpinnerMaxSpeed / 60f; } else { SpinnerSpeed = 0f; } } Rb.MoveRotation(Quaternion.Euler(Rb.rotation.eulerAngles.x, Rb.rotation.eulerAngles.y + SpinnerSpeed * Time.fixedDeltaTime, Rb.rotation.eulerAngles.z)); }
protected override void Move() { Vector3 targetDir = Lane.Paths[PathIndex].PathPoints[PathPointIndex].Point - transform.position; float step = Speed * Time.deltaTime; Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0F); Rb.MoveRotation(Quaternion.LookRotation(newDir)); Rb.MovePosition(transform.position + (Target.Point - transform.position).normalized * step); }
/// <summary> Fixed update. </summary> public virtual void FixedUpdate() { float distance = Vector3.Distance(lastPos, transform.position); Animator.SetMovementDistance(distance); CheckGrounding(); Vector3 moveDelta = IntendedVelocity * Time.fixedDeltaTime; if (moveDelta.sqrMagnitude > 0.001) { if (isGrounded == false) { GroundCheckResult groundCheckResult = CheckGroundSimple(); if (groundCheckResult.RaycastHitAnything && groundCheckResult.IsGrounded) { Rb.MovePosition(groundCheckResult.GroundHit.point); CheckGrounding(); } } if (isGrounded) { moveDelta = Vector3.ProjectOnPlane(moveDelta, groundHit.normal); } Rb.velocity += moveDelta; Debug.DrawRay(Rb.position, moveDelta * 100, Color.red); } else { if (isGrounded == false) { Debug.Log(moveDelta); } Rb.velocity += moveDelta; Debug.DrawRay(Rb.position, moveDelta * 100, Color.green); } if (IntendedVelocity.x0z().IsApproximatelyVectorZero() == false) { lookRotation = Quaternion.LookRotation(IntendedVelocity.x0z().normalized); } Rb.MoveRotation(lookRotation); Animator.SetGrounding(isGrounded); lastPos = transform.position; }