how can I change the script so that I can rotate the object with the rigidbody component ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mehanic : MonoBehaviour
{
public Transform detail1;
public Transform detail2;
public Transform detail3;
void FixedUpdate()
{
if (Input.GetKey(KeyCode.E))
{
//hinge.GetComponent(ConfigurableJoint).lowAngularXLimit = 10f;
detail1.localRotation = Quaternion.RotateTowards(detail1.localRotation, Quaternion.Euler(new Vector3(30, 0, 0)), 20f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.Q))
{
detail1.localRotation = Quaternion.RotateTowards(detail1.localRotation, Quaternion.Euler(new Vector3(-30, 0, 0)), 20f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.Y))
{
detail2.localRotation = Quaternion.RotateTowards(detail2.localRotation, Quaternion.Euler(new Vector3(44, 0, 0)), 20f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.U))
{
detail2.localRotation = Quaternion.RotateTowards(detail2.localRotation, Quaternion.Euler(new Vector3(-21, 0, 0)), 20f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.N))
{
detail3.localRotation = Quaternion.RotateTowards(detail3.localRotation, Quaternion.Euler(new Vector3(40, 0, 0)), 20f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.M))
{
detail3.localRotation = Quaternion.RotateTowards(detail3.localRotation, Quaternion.Euler(new Vector3(-40, 0, 0)), 20f * Time.deltaTime);
}
}
}