Untitled
unknown
csharp
a year ago
891 B
9
Indexable
protected virtual void Rotate()
{
transformNormal = Vector3.Slerp(transformNormal, groundNormal, Time.fixedDeltaTime * 8);
// if (!Math.IsApproximate(rb.velocity, Vector3.zero, 0.2f))
// {
// Vector3 lookDir = transform.forward;
// lookDir = Vector3.Slerp(transform.forward, Vector3.ProjectOnPlane(rb.velocity, transformNormal).normalized, Time.fixedDeltaTime * 16f);
// Quaternion rotation = Quaternion.LookRotation(lookDir, transformNormal);
// transform.rotation = rotation;
// }
Vector3 velocity = rb.velocity;
velocity = Vector3.ProjectOnPlane(velocity, groundNormal);
if (velocity.magnitude > 0.2f)
{
Quaternion rotation = Quaternion.LookRotation(velocity, transformNormal);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 20f);
}
}Editor is loading...
Leave a Comment