- Home /
torque controlled smooth rotation
I have a simple spaceship-like character that I want to torque to match surface normal
"Collider[] col; col = Physics.OverlapSphere (transform.position, 4000); foreach (Collider collided in col) {
if (collided.CompareTag ("Planet")) {
if (Physics.Raycast (transform.position, (collided.transform.position - transform.position).normalized, out surface, 1000)) {
Vector3 toNormal = Vector3.Cross (transform.rotation Vector3.up, surface.normal.normalized);
Vector3 targRot = toNormal.normalized Mathf.Clamp ((toNormal.magnitude tqeFollow), 0, maxTqe);
Vector3 tqe = targRot - rb.angularVelocity;
if (toNormal.magnitude < deadzone)
rb.AddTorque (tqe gravTorque);
}
}
}
this is how I'm currently achieving this and it works but I want it to interpolate between smoother and I thought about using a bezier curve but that seems to require a start and end where I need it to be continuous.