JointDrive SetSpringToMid()
    {
        //store the drive of the joint
        JointDrive yDrive = TargetConfigurableJoint /*GetComponent<ConfigurableJoint> ()*/.yDrive;

        //set spring settings
        yDrive.positionSpring = springToMid;
        yDrive.positionDamper = damperToMid;
        TargetConfigurableJoint /*GetComponent<ConfigurableJoint> ()*/.targetPosition = new Vector3(0, 0, 0);

        //set where the spring is currently springing to
        springTo = SpringTo.mid;

        return(yDrive);
    }
    JointDrive SetSpringToNone()
    {
        //store the drive of the joint
        JointDrive yDrive = TargetConfigurableJoint /*GetComponent<ConfigurableJoint> ()*/.yDrive;

        //set spring settings
        yDrive.positionSpring = 0.0f;
        yDrive.positionDamper = 0.0f;
        TargetConfigurableJoint /*GetComponent<ConfigurableJoint> ()*/.targetPosition = Vector3.zero;

        //set where the spring is currently springing to
        springTo = SpringTo.none;

        return(yDrive);
    }
コード例 #3
0
    JointSpring SetSpringToMin()
    {
        //set to using spring
        GetComponent <HingeJoint> ().useSpring = true;

        //get the spring settings from the joint
        JointSpring spring = GetComponent <HingeJoint> ().spring;

        //set spring settings to minimum
        spring.spring         = springToMin;
        spring.damper         = damperToMin;
        spring.targetPosition = limitMin;

        //set where the spring is currently springing to
        springTo = SpringTo.min;

        return(spring);
    }
コード例 #4
0
    JointSpring SetSpringToNone()
    {
        //set to not using spring
        GetComponent <HingeJoint> ().useSpring = false;

        //get the spring settings from the joint
        JointSpring spring = GetComponent <HingeJoint> ().spring;

        //set spring settings
        spring.spring         = 0.0f;
        spring.damper         = 0.0f;
        spring.targetPosition = 0.0f;

        //set where the spring is currently springing to
        springTo = SpringTo.none;

        return(spring);
    }
    JointDrive SetSpringToMin()
    {
        //store the drive of the joint
        JointDrive yDrive = TargetConfigurableJoint /*GetComponent<ConfigurableJoint> ()*/.yDrive;

        //reference to the parent rail
        VRBasics_Rail rail = transform.parent.gameObject.GetComponent <VRBasics_Rail> ();

        //set spring settings
        yDrive.positionSpring = springToMin;
        yDrive.positionDamper = damperToMin;
        TargetConfigurableJoint /*GetComponent<ConfigurableJoint> ()*/.targetPosition = new Vector3(0, -(rail.length * 0.5f), 0);

        //set where the spring is currently springing to
        springTo = SpringTo.min;

        return(yDrive);
    }
コード例 #6
0
    JointSpring SetSpringToMid()
    {
        //set to using spring
        GetComponent <HingeJoint> ().useSpring = true;

        //get the spring settings from the joint
        JointSpring spring = GetComponent <HingeJoint> ().spring;

        //how far is the hinge capable of swinging
        float degreesOfSwing = limitMax - limitMin;
        //the angle in the middle of the entire range
        float middleAngle = limitMax - (degreesOfSwing * 0.5f);

        //set spring settings to middle
        spring.spring         = springToMid;
        spring.damper         = damperToMid;
        spring.targetPosition = middleAngle;

        //set where the spring is currently springing to
        springTo = SpringTo.mid;

        return(spring);
    }