Esempio n. 1
0
    private void GatherInput(NativeArray <float> input)
    {
        var currIndex = 0;

        for (int i = 0; i < orderedMovingParts.Length; i++)
        {
            for (int j = 0; j < orderedMovingParts[i].input.Length; j++)
            {
                input[currIndex] = orderedMovingParts[i].input[j];
                currIndex++;
            }
        }
        var bodyY = JointHandler.NormalizeValue(body.localPosition.y, startingBodyY * 0.8f, startingBodyY * 1.2f);

        input[currIndex] = bodyY;
        currIndex++;
        int angleDeviation = 45;

        input[currIndex] = JointHandler.NormalizeValue(JointHandler.AdjustRotation(body.localEulerAngles.x), _startingBodyRotation.x - angleDeviation, _startingBodyRotation.x + angleDeviation);
        currIndex++;
        input[currIndex] = JointHandler.NormalizeValue(JointHandler.AdjustRotation(body.localEulerAngles.y), _startingBodyRotation.y - angleDeviation, _startingBodyRotation.y + angleDeviation);
        currIndex++;
        input[currIndex] = JointHandler.NormalizeValue(JointHandler.AdjustRotation(body.localEulerAngles.z), _startingBodyRotation.z - angleDeviation, _startingBodyRotation.z + angleDeviation);
        currIndex++;
        input[currIndex] = (float)(1 / (Exp(-body.localPosition.z) + 1)) * 2 - 1;
        currIndex++;
    }
Esempio n. 2
0
    private void ForEachJoint(GameObject link, JointHandler connectedJointHandler, JointHandler unconnectedJointHandler)
    {
        var joints = link.GetComponents <SpringJoint>();

        foreach (SpringJoint joint in joints)
        {
            if (joint.connectedBody == null)
            {
                unconnectedJointHandler(joint);
            }
            else
            {
                connectedJointHandler(joint);
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     Debug.Log("x:" + JointHandler.AdjustRotation(transform.localEulerAngles.x) + "y:" + JointHandler.AdjustRotation(transform.localEulerAngles.y) + "z:" + JointHandler.AdjustRotation(transform.localEulerAngles.z));
 }
Esempio n. 4
0
 private void ForEachUnconnectedJoint(GameObject link, JointHandler jointHandler)
 {
     ForEachJoint(link, joint => {}, jointHandler);
 }