Example #1
0
    private void Reset()
    {
        //Places legs at initial position

        //Set all joint target angles to zero
        Quaternion  quat   = Quaternion.Euler(0, 0, 0);
        JointSpring spring = new JointSpring();

        spring.spring = spring_const;
        spring.damper = damper;

        hip_right.targetRotation = quat;
        knee_right.spring        = spring;

        hip_left.targetRotation = quat;
        knee_left.spring        = spring;

        //Set rotations of all body parts to zero
        body.transform.rotation        = quat;
        upper_right.transform.rotation = quat;
        lower_right.transform.rotation = quat;
        upper_left.transform.rotation  = quat;
        lower_left.transform.rotation  = quat;

        //Set positions of all parts to inital ones
        body.transform.position        = new Vector3(1, 5, 0);
        upper_right.transform.position = new Vector3(2, 4, 0);
        lower_right.transform.position = new Vector3(2, 1, 0);
        upper_left.transform.position  = new Vector3(0, 4, 0);
        lower_left.transform.position  = new Vector3(0, 1, 0);

        //Set velocity of all parts to zero
        ResetVelocity(body);
        ResetVelocity(upper_right);
        ResetVelocity(lower_right);
        ResetVelocity(upper_left);
        ResetVelocity(lower_left);

        //Set net activities to zero
        net.ResetActivities();
    }