Exemplo n.º 1
0
    float CalculateGrabDistance()
    {
        SVRA_GrabbableObject grabbable = grabConnection.ConnectedGameObject().GetComponent <SVRA_GrabbableObject>();
        Vector3 grabbedAnchorPosition  = grabbable.WorldAnchorPosition();

        return(Vector3.Distance(transform.position, grabbedAnchorPosition));
    }
Exemplo n.º 2
0
    public static ConfigurableJoint JointToConnect(GameObject jointObject, Rigidbody desiredObject, Quaternion controllerRotation)
    {
        SVRA_GrabbableObject grabbable = desiredObject.gameObject.GetComponent <SVRA_GrabbableObject>();
        ConfigurableJoint    joint     = jointObject.AddComponent <ConfigurableJoint>();

        SetLinearDrive(joint, desiredObject.mass);

        if (grabbable.snapPoint.enable)
        {
            SetAnchor(joint, desiredObject, grabbable.RotatedAnchor());
        }

        if (grabbable.ApplyGripRotation())
        {
            SetAngularDrive(joint, desiredObject.mass);
        }

        if (grabbable.SnapToOrientation())
        {
            SetTargetRotation(joint, desiredObject, grabbable.rotation.localOrientation, controllerRotation);
        }

        joint.connectedBody = desiredObject;

        return(joint);
    }