Rotate Rigidbody towards target rotation using AddTorque()
I have a character moving around and a sword that follows the rotation of that character. The code looks like this:
void Update()
{
Quaternion followRotation = Quaternion.Euler(new Vector3(follow.eulerAngles.x + rotOffset[0], follow.eulerAngles.y + rotOffset[1], follow.eulerAngles.z + rotOffset[2]));
transform.rotation = Quaternion.Slerp(transform.rotation, followRotation, followRotationSpeed * Time.deltaTime);
}
But the problem is the sword clipping through walls. I was trying to find a solution but couldn't. I need to rotate the sword around one axis using RigidBody.AddTorque() to the target rotation similar to Quaternion.Slerp. I would really appreciate if you can help me with this since I've been trying to find the solution for quite a while now.
Comment