object rotation

how can I rotate an object that has a Configurable joint component

Do as in the screenshot.

151522-ex.png

Add this script to “Object Rotation”:

using UnityEngine;

public class Rotation : MonoBehaviour
{
    public float rotSpeedAll = 3;
    public float rotSpeedX = 0.5f;
    public float rotLengthX = 5;
    public float rotSpeedY = 0.5f;
    public float rotLengthY = 7;
    public float rotSpeedZ = 0.5f;
    public float rotLengthZ = 9;

    Transform tr;
    float rtx, rty, rtz;

    void Awake()
    {
        tr = transform;
    }

    void LateUpdate()
    {
        float timeTime = Time.time;
        if (rotSpeedX != 0) rtx = Mathf.PingPong(rotSpeedX * timeTime, rotLengthX);
        else rtx = 0;
        if (rotSpeedY != 0) rty = Mathf.PingPong(rotSpeedY * timeTime, rotLengthY);
        else rty = 0;
        if (rotSpeedZ != 0) rtz = Mathf.PingPong(rotSpeedZ * timeTime, rotLengthZ);
        else rtz = 0;
        tr.Rotate(new Vector3(rtx, rty, rtz), rotSpeedAll * Time.deltaTime);
    }
}

A simpler option if no settings are required:

using UnityEngine;

public class Rotation : MonoBehaviour
{
    public float rotSpeed = 3;

    Transform tr;

    void Awake()
    {
        tr = transform;
    }

    void LateUpdate()
    {
        tr.Rotate(new Vector3(1, 0, 0), rotSpeed * Time.deltaTime); // new Vector3(1, 0, 0) - Direction of rotation
    }
}