Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public AnimationCurve rotationCurve;
- public float targetSpeed;
- public float speedlerp;
- float currentSpeed;
- float curvePosition;
- public bool isRotating;
- void Update()
- {
- if(isRotating)
- {
- currentSpeed = Mathf.Lerp(currentSpeed, targetSpeed, speedlerp * Time.deltaTime);
- }
- else
- {
- currentSpeed = Mathf.Lerp(currentSpeed, 0, speedlerp * Time.deltaTime);
- }
- curvePosition += Time.deltaTime;
- float curveMultiplier = rotationCurve.Evaluate(curvePosition);
- float finalSpeed = currentSpeed * curveMultiplier;
- transform.Rotate(Vector3.right, finalSpeed * Time.deltaTime, Space.Self);
- }
Advertisement
Add Comment
Please, Sign In to add comment