コード例 #1
0
    void Update()
    {
        //Directions obtained from CC_CANOE class. We use the Right wand and Head for orientation.
        //Where the right wand is pointed is the direction the player will move
        Vector3 forwardDir = CC_CANOE.WandGameObject(Wand.Right).transform.forward;
        Vector3 rightDir   = CC_CANOE.HeadGameObject().transform.right;

        rightDir = Vector3.Normalize(Vector3.ProjectOnPlane(rightDir, Vector3.up));
        Vector3 upDir = Vector3.up;

        //The input from the trigger axis of the left wand
        float forward = CC_INPUT.GetAxis(Wand.Right, WandAxis.Trigger);

        //Move the CharacterController attached to the CC_CANOE.
        Vector3 movement = forwardDir * forward;

        charCont.Move(movement * Time.deltaTime * moveSpeed);

        //The input from the X and Y axis of the right wand joystick.
        yAxisChange += CC_INPUT.GetAxis(Wand.Right, WandAxis.XAxis) * Time.deltaTime * lookSpeed;
        yAxisChange  = yAxisChange % 360.0f;
        xAxisChange += CC_INPUT.GetAxis(Wand.Right, WandAxis.YAxis) * Time.deltaTime * lookSpeed;
        xAxisChange  = Mathf.Clamp(xAxisChange, -maxPitch, maxPitch);

        //Change the direction the CharacterController is facing.
        charCont.transform.rotation = Quaternion.identity;
        charCont.transform.RotateAround(CC_CANOE.CanoeGameObject().transform.position, Vector3.up, yAxisChange);
        charCont.transform.RotateAround(CC_CANOE.CanoeGameObject().transform.position, rightDir, xAxisChange);
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        //Head tracking
        Transform source = CC_CANOE.HeadGameObject().transform;

        headReference.transform.position      = convertPosition(source.position);
        headReference.transform.localRotation = convertRotation(source.rotation);

        //Left wand tracking
        source = CC_CANOE.WandGameObject(Wand.Left).transform;
        leftWandReference.transform.position      = convertPosition(source.position);
        leftWandReference.transform.localRotation = convertRotation(source.rotation);

        //Right wand tracking
        source = CC_CANOE.WandGameObject(Wand.Right).transform;
        rightWandReference.transform.position      = convertPosition(source.position);
        rightWandReference.transform.localRotation = convertRotation(source.rotation);

        //Waist tracking
        waistReference.transform.localPosition = convertPuckPosition(waistReference.transform.localPosition, 0);
        waistReference.transform.localRotation = convertPuckRotation(0);

        //Left foot tracking
        leftFootReference.transform.localPosition = convertPuckPosition(leftFootReference.transform.localPosition, 1);
        leftFootReference.transform.localRotation = convertPuckRotation(1);

        //Right foot tracking
        rightFootReference.transform.localPosition = convertPuckPosition(rightFootReference.transform.localPosition, 2);
        rightFootReference.transform.localRotation = convertPuckRotation(2);
    }
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     wandTransform  = CC_CANOE.WandTransform(wand);
     upParticles    = transform.GetChild(0).gameObject;
     downParticles  = transform.GetChild(1).gameObject;
     leftParticles  = transform.GetChild(2).gameObject;
     rightParticles = transform.GetChild(3).gameObject;
 }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        headPos = CC_CANOE.HeadGameObject().transform.position;

        ccPosition = controller.center;

        transform.position = new Vector3(headPos.x + originalPos.x, 0, headPos.z + originalPos.z);
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        projectile.transform.position = new Vector3(wandTransform.position.x,
                                                    wandTransform.position.y,
                                                    wandTransform.position.z);
        permanentTrail.transform.position = projectile.transform.position;

        if (CC_INPUT.GetButtonDown(wand, WandButton.Trigger))
        {
            GameObject tempProjectile = Instantiate(projectile);
            tempProjectile.AddComponent <DestroyProjectile>();
            tempProjectile.GetComponent <Rigidbody>().isKinematic = false;
            tempProjectile.GetComponent <Rigidbody>().AddForce(CC_CANOE.WandGameObject(wand).transform.forward *projectileForce);
        }
    }
コード例 #6
0
    /// <summary>
    /// Inputs for head movements in simulator mode.
    /// </summary>
    /// <param name="mouseX">Mouse x-position.</param>
    /// <param name="mouseY">Mouse y-position.</param>
    private void headSimulation(float mouseX, float mouseY)
    {
        float same;

        //Turn head.
        if (Input.GetKey(KeyCode.Q) && CC_CANOE.keyboardControls)
        {
            headRotation = Quaternion.AngleAxis(mouseX * headSpan - (headSpan / 2), Vector3.up) * Quaternion.AngleAxis(-(mouseY * headSpan / 2 - (headSpan / 4)), Vector3.right);
        }

        //Move the head left/right and forward/backward.
        if (Input.GetKey(KeyCode.Z) && CC_CANOE.keyboardControls)
        {
            same         = headPosition.z;
            headPosition = new Vector3(mouseX * headXSpan - (headXSpan / 2), mouseY * headYSpan / 2 + shoulderHeight, same);
            //Moving the Character Controller with the head movement
            same = CC_CANOE.CanoeCharacterController().center.y;
            CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);
        }

        //Move the head left/right and up/down.
        if (Input.GetKey(KeyCode.C) && CC_CANOE.keyboardControls)
        {
            same         = headPosition.y;
            headPosition = new Vector3(mouseX * headXSpan - (headXSpan / 2), same, mouseY * headZSpan / 2);
            //Moving the Character Controller with the head movement
            same = CC_CANOE.CanoeCharacterController().center.y;
            CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);
        }

        //Roll the head
        if (Input.GetKey(KeyCode.E) && CC_CANOE.keyboardControls)
        {
            if (twistHeadStarted == 0)
            {
                twistHeadStarted = 1;
                saveHeadRotation = headRotation;
            }
            else
            {
                headRotation = saveHeadRotation * Quaternion.AngleAxis(-(mouseX * 180 - 90), Vector3.forward);
            }
        }
        else
        {
            twistHeadStarted = 0;
        }
    }
コード例 #7
0
    //Get the color from the color picker quad and set color to the wand's line renderer
    private void getColor(Wand wand)
    {
        //The line pointer origin is the Wand's world offset position.
        Vector3 rayOrigin = leftRayOrigin.transform.position;

        if (wand == Wand.Right)
        {
            rayOrigin = rightRayOrigin.transform.position;
        }
        //The line pointer direction is the Wand's transform forward direction.
        Vector3 rayDirection = CC_CANOE.WandTransform(wand).forward;

        //Draw the line pointer
        drawLinePointer(wand, rayOrigin, rayDirection);

        //Raycast stuff
        RaycastHit hit;
        Renderer   rend;

        if (Physics.Raycast(rayOrigin, rayDirection, out hit, 30))
        {
            if (hit.transform.gameObject.name.Equals("ColorPicker"))
            {
                rend = hit.transform.GetComponent <Renderer>();
                Texture2D textureMap = rend.material.mainTexture as Texture2D;
                Vector2   pixelUV    = hit.textureCoord;

                if (wand == Wand.Left)
                {
                    leftColor = textureMap.GetPixelBilinear(pixelUV.x, pixelUV.y);
                    linePointer1.startColor = leftColor;
                    linePointer1.endColor   = leftColor;
                    line1.startColor        = leftColor;
                    line1.endColor          = leftColor;
                }
                else if (wand == Wand.Right)
                {
                    rightcolor = textureMap.GetPixelBilinear(pixelUV.x, pixelUV.y);
                    linePointer2.startColor = rightcolor;
                    linePointer2.endColor   = rightcolor;
                    line2.startColor        = rightcolor;
                    line2.endColor          = rightcolor;
                }
            }
        }
    }
コード例 #8
0
    void Start()
    {
        //Instantiate an empty object to be used as ray origin. This is needed to avoid colliding with
        //the sphere collider on the wand before it can collide with the color wheel.
        leftRayOrigin  = Instantiate(new GameObject(), CC_CANOE.WandGameObject(Wand.Left).transform);
        rightRayOrigin = Instantiate(new GameObject(), CC_CANOE.WandGameObject(Wand.Right).transform);
        leftRayOrigin.transform.localPosition = rightRayOrigin.transform.localPosition = offset;

        lineCount1 = 0;
        lineCount2 = 0;
        leftColor  = new Color(1, 0.88f, 0.49f);
        rightcolor = new Color(0.94f, 0.28f, 0.13f);

        //Setup the line pointers.
        linePointer1.positionCount = 0;
        linePointer1.startWidth    = 0.01f;
        linePointer1.endWidth      = 0.01f;
        linePointer2.positionCount = 0;
        linePointer2.startWidth    = 0.01f;
        linePointer2.endWidth      = 0.01f;
    }
コード例 #9
0
    // Use this for initialization
    void Start()
    {
        animator = GetComponent <Animator>();

        controller = CC_CANOE.CanoeCharacterController();

        parentTransform    = transform.GetComponentInParent <Transform>();
        headTransform      = CC_CANOE.HeadGameObject().gameObject.transform;
        leftHandTransform  = CC_CANOE.WandGameObject(Wand.Left).gameObject.transform;
        rightHandTransform = CC_CANOE.WandGameObject(Wand.Right).gameObject.transform;

        //Initial call to chest puck
        VRPN.vrpnTrackerQuat("CC_FLAT_PUCK0@" + CC_CONFIG.innovatorIP, 0);

        //Brings model out of ground
        offset = new Vector3(0, 2f * transform.GetChild(0).GetComponent <SkinnedMeshRenderer>().bounds.extents.x, 0);
        transform.localPosition = offset;

        leftMirrorGoal  = transform.parent.GetChild(1).transform;
        rightMirrorGoal = transform.parent.GetChild(2).transform;
    }
コード例 #10
0
 void Start()
 {
     wandPosition = new Vector3[2];
     wandRotation = new Quaternion[2];
     setDefaultPositions();
     canoe = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();
     if (canoe.isVive())
     {
         yaw_pitchKey          = KeyCode.T;
         rollKey               = KeyCode.O;
         left_right_up_downKey = KeyCode.V;
         left_right_in_outKey  = KeyCode.Comma;
         if (CC_CONFIG.IsDestiny())
         {
             addViveClusterInputs();
         }
     }
     else if (canoe.isOptiTrack() && CC_CONFIG.IsDestiny())
     {
         addOptiTrackClusterInputs();
     }
 }
コード例 #11
0
    /// <summary>
    /// Updates the camera perspective for one group of screens.
    /// </summary>
    /// <param name="cameras">Array of cameras.</param>
    /// <param name="cameraIndex">Index of the camera to update.</param>
    /// <param name="panOptic">True for panoptic view mode.</param>
    public void UpdateCameraPerspective(Camera[] cameras, int cameraIndex, bool panOptic)
    {
        //Get this camera rig's projection screens
        GameObject[] projScreens = new GameObject[4];
        if (cameraIndex == 8)
        {
            cameraIndex = 0;
        }
        projScreens[0] = Screens.transform.GetChild(cameraIndex * 4).gameObject;
        projScreens[1] = Screens.transform.GetChild(cameraIndex * 4 + 1).gameObject;
        projScreens[2] = Screens.transform.GetChild(cameraIndex * 4 + 2).gameObject;
        projScreens[3] = Screens.transform.GetChild(cameraIndex * 4 + 3).gameObject;

        //Set each camera's rotation depending on PanOptic setting
        if (panOptic)
        {
            for (int i = 0; i < 4; i++)
            {
                cameras[i].transform.LookAt(projScreens[i].transform, CC_CANOE.CanoeGameObject().transform.up);
            }
        }
        else
        {
            for (int i = 0; i < 4; i++)
            {
                cameras[i].transform.localEulerAngles = Vector3.zero;
            }
        }

        //Set each camera's projection
        for (int i = 0; i < 4; i++)
        {
            perspectiveOffCenter(cameras[i], projScreens[i]);
            perspectiveOffCenter(cameras[i].transform.GetChild(0).GetComponent <Camera>(), projScreens[i]);
            perspectiveOffCenter(cameras[i].transform.GetChild(1).GetComponent <Camera>(), projScreens[i]);
        }
    }
コード例 #12
0
    public override void OnInspectorGUI()
    {
        //Disconnect the prefab instance from the original prefab
        bool isPrefabOriginal = (PrefabUtility.GetPrefabParent(target) == null) && (PrefabUtility.GetPrefabObject(target) != null);

        if (!isPrefabOriginal)
        {
            PrefabUtility.DisconnectPrefabInstance(target);
        }

        EditorGUI.BeginChangeCheck();

        GUILayout.Space(10);
        EditorGUILayout.LabelField("Grabber Settings", EditorStyles.boldLabel);

        bool enableGrabbing = EditorGUILayout.Toggle(new GUIContent("Enable Grabbing", "Toggles grabbing using the specified wand."), grabTarget.enableGrabbing);

        //Disable grabbing if enable grabbin is false
        EditorGUI.BeginDisabledGroup(!enableGrabbing);

        bool grabWithTrigger = EditorGUILayout.Toggle(new GUIContent("Grab With Trigger", "Toggles navigation with trigger. Overrides Grab Button."), grabTarget.grabWithTrigger);

        //Disable grab button if grab with trigger is true
        EditorGUI.BeginDisabledGroup(grabWithTrigger);

        WandButton validGrabButton = grabTarget.grabButton;
        WandButton grabButton      = (WandButton)EditorGUILayout.EnumPopup(new GUIContent("Grab Button", "Select button to be used to grab."), grabTarget.grabButton);

        //End grab button disabled group
        EditorGUI.EndDisabledGroup();

        //End grabber disabled group
        EditorGUI.EndDisabledGroup();

        GUILayout.Space(20);

        EditorGUI.EndChangeCheck();

        Undo.RecordObject(grabTarget, "Updated Grabber Settings");
        canoe = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();

        //GRABBER STARTS
        grabTarget.enableGrabbing  = enableGrabbing;
        grabTarget.grabWithTrigger = grabWithTrigger;

        string location = "CCaux_Grabber on " + grabTarget.gameObject.name + "/\"Grabber Settings\"/\"Grab Button\"";

        //Button logic to keep user from selecting incorrect input for grab button
        if (canoe.isVive() && !CC_INPUT.IsViveInput(grabButton))
        {
            if (!CC_INPUT.IsEnumSeparator(grabButton))
            {
                if (!CC_INPUT.IsViveInput(validGrabButton))
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not Vive input. Defaulting to \"Menu\" button.");
                    grabButton = grabTarget.grabButton = WandButton.Menu;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not Vive input.");
                    grabButton = grabTarget.grabButton = validGrabButton;
                }
            }
            throw new ExitGUIException();
        }
        else if (canoe.isOptiTrack() && !CC_INPUT.IsOptiTrackInput(grabButton))
        {
            if (!CC_INPUT.IsEnumSeparator(grabButton))
            {
                if (!CC_INPUT.IsOptiTrackInput(validGrabButton))
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not OptiTrack input. Defaulting to \"X\" button.");
                    grabButton = grabTarget.grabButton = WandButton.X;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not OptiTrack input.");
                    grabButton = grabTarget.grabButton = validGrabButton;
                }
            }
            throw new ExitGUIException();
        }
        else
        {
            grabTarget.grabButton = grabButton;
        }
        //Button logic end

        //GRABBER ENDS
    }
コード例 #13
0
 private void Awake()
 {
     canoeTarget = (CC_CANOE)target;
 }
コード例 #14
0
    /// <summary>
    /// Obtain tracker information.
    /// </summary>
    private void getTrackerInformation()
    {
        if (CC_CONFIG.IsDestiny())
        {
            Vector3    position = new Vector3(0, 0, 0);
            Quaternion rotation = Quaternion.identity;

            if (canoe.isVive())
            {
                //Update head ClusterInput entry
                position = ClusterInput.GetTrackerPosition("head");
                rotation = ClusterInput.GetTrackerRotation("head");
                //Angle puck so flat section is bottom
                //Change "Camera Forward Tilt" in editor to change tilt if hat/helmet is angled
                rotation *= Quaternion.AngleAxis(90 - canoe.cameraForwardTilt, Vector3.left);
                rotation *= Quaternion.AngleAxis(180, Vector3.up);
                convertHeadTracking(position, rotation);

                //Update left controller ClusterInput entries
                position = ClusterInput.GetTrackerPosition("leftWand");
                rotation = ClusterInput.GetTrackerRotation("leftWand");
                convertWandTracking(Wand.Left, position, rotation);

                //Update right controller ClusterInput entries
                position = ClusterInput.GetTrackerPosition("rightWand");
                rotation = ClusterInput.GetTrackerRotation("rightWand");
                convertWandTracking(Wand.Right, position, rotation);

                //Moving the Character Controller with the head movement
                float same = CC_CANOE.CanoeCharacterController().center.y;
                CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);
            }
            else if (canoe.isOptiTrack())
            {
                //Head position and rotation
                position = ClusterInput.GetTrackerPosition("head");
                //position = new Vector3(position.x, position.y, -position.z);
                rotation = ClusterInput.GetTrackerRotation("head");
                convertHeadTracking(position, rotation);

                //Left wand position and rotation
                position = ClusterInput.GetTrackerPosition("leftWand");
                rotation = ClusterInput.GetTrackerRotation("leftWand");
                convertWandTracking(Wand.Left, position, rotation);

                //Right wand position and rotation
                position = ClusterInput.GetTrackerPosition("rightWand");
                rotation = ClusterInput.GetTrackerRotation("rightWand");
                convertWandTracking(Wand.Right, position, rotation);

                //Moving the Character Controller with the head movement
                float same = CC_CANOE.CanoeCharacterController().center.y;

                CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);
            }
        }
        else
        {
            if (CC_CONFIG.IsInnovator())
            {
                //if (checkInnovatorTracking()) {
                headPosition = convertToLeftHandPosition(VRPN.vrpnTrackerPos("CC_FLAT_HEAD@" + CC_CONFIG.innovatorIP, 0));
                headRotation = convertToLeftHandRotation(VRPN.vrpnTrackerQuat("CC_FLAT_HEAD@" + CC_CONFIG.innovatorIP, 0) * Quaternion.AngleAxis(90 - canoe.cameraForwardTilt, Vector3.left) * Quaternion.AngleAxis(180, Vector3.up));

                //Moving the Character Controller with the head movement
                float same = CC_CANOE.CanoeCharacterController().center.y;
                CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);

                //Wands rotation and position.
                wandPosition[0] = convertToLeftHandPosition(VRPN.vrpnTrackerPos("CC_FLAT_WAND0@" + CC_CONFIG.innovatorIP, 0));
                wandPosition[1] = convertToLeftHandPosition(VRPN.vrpnTrackerPos("CC_FLAT_WAND1@" + CC_CONFIG.innovatorIP, 0));
                wandRotation[0] = convertToLeftHandRotation(VRPN.vrpnTrackerQuat("CC_FLAT_WAND0@" + CC_CONFIG.innovatorIP, 0));
                wandRotation[1] = convertToLeftHandRotation(VRPN.vrpnTrackerQuat("CC_FLAT_WAND1@" + CC_CONFIG.innovatorIP, 0));
            }
            else
            {
                setDefaultPositions();
            }
        }
    }
コード例 #15
0
    // Update is called once per frame
    void Update()
    {
        Transform wandTransform = CC_CANOE.WandTransform(wand);
        Vector3   offset        = new Vector3(wandTransform.position.x,
                                              wandTransform.position.y + verticalOffset,
                                              wandTransform.position.z);

        float angle = Mathf.Atan2(CC_INPUT.GetAxis(wand, WandAxis.YAxis), CC_INPUT.GetAxis(wand, WandAxis.XAxis));

        if (angle < 0f)
        {
            angle += 2 * Mathf.PI;
        }

        angle = angle * (180f / Mathf.PI);

        if (CC_INPUT.GetButtonDown(wand, WandButton.TrackpadClick))
        {
            if ((angle >= 45f) && (angle <= 135f))
            {
                Debug.Log("Up object selected");
                lanternObj   = upObject;
                chosenButton = WandButton.Up;
            }
            else if ((angle >= 225f) && (angle <= 315f))
            {
                Debug.Log("Down object selected");
                lanternObj   = downObject;
                chosenButton = WandButton.Down;
            }
            else if ((angle > 135f) && (angle < 225f))
            {
                Debug.Log("Left object selected");
                lanternObj   = leftObject;
                chosenButton = WandButton.Left;
            }
            else if (((angle >= 0) && (angle < 45)) || ((angle > 315) && (angle <= 360f)))
            {
                Debug.Log("Right object selected");
                lanternObj   = rightObject;
                chosenButton = WandButton.Right;
            }
        }

        if (CC_INPUT.GetButtonDown(wand, WandButton.TrackpadClick))
        {
            lanternObj.transform.localScale = Vector3.zero;
            Vector3    rotation = lanternObj.transform.eulerAngles;
            Quaternion quat     = Quaternion.identity;
            lantern = Instantiate(lanternObj, offset, quat);
            lantern.gameObject.SetActive(true);
            lantern.transform.position = offset;
        }
        else if (CC_INPUT.GetButtonPress(wand, WandButton.TrackpadClick))
        {
            lantern.transform.position = offset;
        }
        else if (CC_INPUT.GetButtonUp(wand, WandButton.TrackpadClick))
        {
            lantern.GetComponent <Rigidbody>().isKinematic = false;
            lantern.GetComponent <Rigidbody>().AddForce(new Vector3(0, releaseForce, 0));
            lantern.GetComponent <Lantern>().startExpiring = true;
        }
    }
コード例 #16
0
    // Update is called once per frame
    void Update()
    {
        //Default color
        Color color = Color.white;

        updateModel();
        updateTrackpad();

        //On the first frame of the click, instantiate a projectile at the position of the trackpad click
        if (CC_INPUT.GetButtonDown(Wand.Left, WandButton.TrackpadClick))
        {
            Debug.Log("trackpad just clicked");
            //Color is calculated using the angle of the click
            color            = new Color(Mathf.Cos(angle), Mathf.Cos(angle + (3 * Mathf.PI / 4)), Mathf.Cos(angle - (3 * Mathf.PI / 4)));
            controlledObject = Instantiate(projectile, new Vector3(x, y + transform.position.y, transform.position.z), Quaternion.identity);
            controlledObject.GetComponent <Renderer>().material.color = color;
            controlledObject.name = "obj_" + projectileIncrement;
            projectileIncrement   = (projectileIncrement + 1) % projectileLimit;
            //When the trackpad is held, the projectile follows the position of the trackpad click and its color is updated
            //to match the new angle
        }
        else if (CC_INPUT.GetButtonPress(Wand.Left, WandButton.TrackpadClick) && (controlledObject != null))
        {
            Debug.Log("trackpad being held");
            controlledObject.transform.position = new Vector3(x, y + transform.position.y, transform.position.z);
            color = new Color(Mathf.Cos(angle), Mathf.Cos(angle + (3 * Mathf.PI / 4)), Mathf.Cos(angle - (3 * Mathf.PI / 4)));
            controlledObject.GetComponent <Renderer>().material.color = color;
            //When the trackpad is released, the force is added to the projectile at the angle it was released at
        }
        else if (CC_INPUT.GetButtonUp(Wand.Left, WandButton.TrackpadClick))
        {
            Debug.Log("trackpad just released");
            //A random z-axis force is applied to the projectile
            float force = (float)forceEnum * forceFactor + forceFactor;
            zForce = CC_CANOE.RandomRange(0f, 1f) * force;
            if (CC_CANOE.RandomRange(0, 1) == 0)
            {
                zForce = -zForce;
            }
            //Force is added to the projectile
            if (controlledObject != null)
            {
                controlledObject.GetComponent <Rigidbody>().AddForce(new Vector3(Mathf.Cos(angle) * force, Mathf.Sin(angle) * force, zForce));
            }
            //If an object of the same name exists, destroy it. This enforces the number of projectiles allowed at once.
            if (GameObject.Find("obj_" + projectileIncrement) != null)
            {
                Destroy(GameObject.Find("obj_" + projectileIncrement));
            }
        }

        if (CC_INPUT.GetButtonDown(Wand.Left, WandButton.Trigger))
        {
            forceEnum = (Force)(((int)(forceEnum) + 1) % System.Enum.GetValues(typeof(Force)).Length);
        }

        if (CC_INPUT.GetButtonDown(Wand.Left, WandButton.Grip))
        {
            modelEnum = (Model)(((int)(modelEnum) + 1) % System.Enum.GetValues(typeof(Model)).Length);
            switch (modelEnum)
            {
            case Model.Orb:
                projectile = orbObject;
                break;

            case Model.Cube:
                projectile = cubeObject;
                break;

            default:
                break;
            }
        }

        //Press the left Menu button to delete all existing projectiles
        if (CC_INPUT.GetButtonDown(Wand.Left, WandButton.Menu))
        {
            for (int i = 0; i < projectileLimit; i++)
            {
                if (GameObject.Find("obj_" + i) != null)
                {
                    Destroy(GameObject.Find("obj_" + i));
                    audioSource.Play();
                }
            }
        }

        toggleInfo.text = "Newly spawned projectiles"
                          + "\nwill be " + modelEnum + "s with " + forceEnum + " force";
    }
コード例 #17
0
 // Use this for initialization
 void Start()
 {
     controller  = CC_CANOE.CanoeCharacterController();
     originalPos = transform.position;
 }
コード例 #18
0
    void LateUpdate()
    {
        if (drawWithLeft)
        {
            //Draw line for left wand.
            if (CC_INPUT.GetButtonPress(Wand.Left, WandButton.Down))
            {
                //If lineCount is zero then we are starting a new line.
                if (lineCount1 == 0)
                {
                    newLine1 = Instantiate(line1, CC_CANOE.WandTransform(Wand.Left).position, CC_CANOE.WandTransform(Wand.Right).rotation);
                }

                lineCount1++;
                newLine1.positionCount = lineCount1;
                newLine1.SetPosition(lineCount1 - 1, CC_CANOE.WandTransform(Wand.Left).position);
            }
            else
            {
                lineCount1 = 0;
            }
            //Color pick for left wand.
            if (CC_INPUT.GetButtonPress(Wand.Left, WandButton.Up))
            {
                getColor(Wand.Left);
            }
            else
            {
                //Erase the line pointer.
                linePointer1.positionCount = 0;
            }
        }

        if (drawWithRight)
        {
            //Draw line for right wand.
            if (CC_INPUT.GetButtonPress(Wand.Right, WandButton.Down))
            {
                //If lineCount is zero then we are starting a new line.
                if (lineCount2 == 0)
                {
                    newLine2 = Instantiate(line2, CC_CANOE.WandTransform(Wand.Right).position, CC_CANOE.WandTransform(Wand.Right).rotation);
                }

                lineCount2++;
                newLine2.positionCount = lineCount2;
                newLine2.SetPosition(lineCount2 - 1, CC_CANOE.WandTransform(Wand.Right).position);
            }
            else
            {
                lineCount2 = 0;
            }
            //Color pick for right wand.
            if (CC_INPUT.GetButtonPress(Wand.Right, WandButton.Up))
            {
                getColor(Wand.Right);
            }
            else
            {
                //Erase the line pointer.
                linePointer2.positionCount = 0;
            }
        }
    }
コード例 #19
0
 // Use this for initialization
 void Start()
 {
     wandTransform = CC_CANOE.WandGameObject(wandToFollow).transform;
 }
コード例 #20
0
 // Use this for initialization
 void Start()
 {
     wandTransform  = CC_CANOE.WandTransform(wand);
     permanentTrail = Instantiate(projectile, projectile.transform.position, projectile.transform.rotation);
 }
コード例 #21
0
    public override void OnInspectorGUI()
    {
        //Get This Target
        navTarget = (CCaux_OmniNavigator)target;
        canoe     = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();
        //Disconnect the prefab instance from the original prefab
        bool isPrefabOriginal = (PrefabUtility.GetPrefabParent(target) == null) && (PrefabUtility.GetPrefabObject(target) != null);

        if (!isPrefabOriginal)
        {
            PrefabUtility.DisconnectPrefabInstance(target);
        }

        EditorGUI.BeginChangeCheck();

        //NAVIGATION STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Navigation Settings", EditorStyles.boldLabel);
        bool enableNavigation = EditorGUILayout.Toggle(new GUIContent("Enable Navigation", "Toggle navigation using navigation input (default is trigger)."), navTarget.enableNavigation);

        //Disable navigation if enable navigation is false
        EditorGUI.BeginDisabledGroup(!enableNavigation);

        bool disableNavigationX = EditorGUILayout.Toggle(new GUIContent("Disable X-Axis Movement", "Toggle movement in the X-axis while navigating."), navTarget.disableNavigationX);
        bool disableNavigationY = EditorGUILayout.Toggle(new GUIContent("Disable Y-Axis Movement", "Toggle movement in the Y-axis while navigating."), navTarget.disableNavigationY);
        bool disableNavigationZ = EditorGUILayout.Toggle(new GUIContent("Disable Z-Axis Movement", "Toggle movement in the Z-axis while navigating."), navTarget.disableNavigationZ);

        CCaux_OmniNavigator.rotationLock lockRotation = (CCaux_OmniNavigator.rotationLock)EditorGUILayout.EnumPopup(new GUIContent("Lock Rotation Around Axis", "Select an axis to lock rotation around."), navTarget.lockRotation);
        Wand wandToUse      = (Wand)EditorGUILayout.EnumPopup(new GUIContent("Navigation Wand", "Select wand to use for navigation."), navTarget.wandToUse);
        bool navWithTrigger = EditorGUILayout.Toggle(new GUIContent("Navigate with Trigger", "Toggles navigation with trigger. Overrides Navigation Button."), navTarget.navWithTrigger);

        //Disable navigation button selection if trigger is used for navigation
        EditorGUI.BeginDisabledGroup(navWithTrigger);
        WandButton validNavButton = navTarget.navButton;
        WandButton navButton      = (WandButton)EditorGUILayout.EnumPopup(new GUIContent("Navigation Button", "Select button to use for navigation."), navTarget.navButton);

        //End navigation button disabled group
        EditorGUI.EndDisabledGroup();

        float moveSpeed   = EditorGUILayout.FloatField(new GUIContent("Movement Speed", "Set navigation movement speed."), navTarget.moveSpeed);
        float rotateSpeed = EditorGUILayout.FloatField(new GUIContent("Rotation Speed", "Set navigation rotation speed."), navTarget.rotateSpeed);

        //NAVIGATION ENDS

        //RESET STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Reset Settings", EditorStyles.boldLabel);
        WandButton validResetButton = navTarget.resetButton;
        WandButton resetButton      = (WandButton)EditorGUILayout.EnumPopup(new GUIContent("Reset Button", "Select button to reset CANOE position."), navTarget.resetButton);
        float      resetSpeed       = EditorGUILayout.FloatField(new GUIContent("Reset Speed", "Set the CANOE's speed when returning to its reset position."), navTarget.resetSpeed);
        Vector3    resetPosition    = EditorGUILayout.Vector3Field(new GUIContent("Reset Position", "Set the CANOE's reset position."), navTarget.resetPosition);
        Vector3    resetRotation    = EditorGUILayout.Vector3Field(new GUIContent("Reset Rotation", "Set the CANOE's reset rotation."), navTarget.resetRotation);

        //RESET ENDS

        //MISC STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Misc Settings", EditorStyles.boldLabel);
        GameObject cursor = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Cursor Object", "Set object to display while navigating."), navTarget.cursor, typeof(Object), true);

        //MISC ENDS

        //End navigation disabled group
        EditorGUI.EndDisabledGroup();

        GUILayout.Space(20);

        EditorGUI.EndChangeCheck();

        Undo.RecordObject(navTarget, "Updated Navigator Settings");
        canoe = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();

        //NAVIGATION STARTS
        navTarget.enableNavigation   = enableNavigation;
        navTarget.disableNavigationX = disableNavigationX;
        navTarget.disableNavigationY = disableNavigationY;
        navTarget.disableNavigationZ = disableNavigationZ;

        navTarget.lockRotation   = lockRotation;
        navTarget.wandToUse      = wandToUse;
        navTarget.navWithTrigger = navWithTrigger;

        string location = "CCaux_OmniNavigator/\"Navigation Settings\"/\"Navigation Button\"";

        //Button logic to keep user from selecting incorrect input for navigation button
        if (canoe.isVive() && !CC_INPUT.IsViveInput(navButton))
        {
            if (!CC_INPUT.IsEnumSeparator(navButton))
            {
                if (!CC_INPUT.IsViveInput(validNavButton))
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not Vive input. Defaulting to \"Menu\" button.");
                    navButton = navTarget.navButton = WandButton.Menu;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not Vive input.");
                    navButton = navTarget.navButton = validNavButton;
                }
            }
            throw new ExitGUIException();
        }
        else if (canoe.isOptiTrack() && !CC_INPUT.IsOptiTrackInput(navButton))
        {
            if (!CC_INPUT.IsEnumSeparator(navButton))
            {
                if (!CC_INPUT.IsOptiTrackInput(validNavButton))
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not OptiTrack input. Defaulting to \"X\" button.");
                    navButton = navTarget.navButton = WandButton.X;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not OptiTrack input.");
                    navButton = navTarget.navButton = validNavButton;
                }
            }
            throw new ExitGUIException();
        }
        else
        {
            navTarget.navButton = navButton;
        }
        //Button logic end

        navTarget.moveSpeed   = moveSpeed;
        navTarget.rotateSpeed = rotateSpeed;
        //NAVIGATION ENDS

        //RESET STARTS
        location = "CCaux_OmniNavigator/\"Reset Settings\"/\"Reset Button\"";

        //Button logic to keep user from selecting incorrect input for reset button
        if (canoe.isVive() && !CC_INPUT.IsViveInput(resetButton))
        {
            if (!CC_INPUT.IsEnumSeparator(resetButton))
            {
                if (!CC_INPUT.IsViveInput(validResetButton))
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not Vive input. Defaulting to \"Menu\" button.");
                    resetButton = navTarget.resetButton = WandButton.Menu;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not Vive input.");
                    resetButton = navTarget.resetButton = validResetButton;
                }
            }
            throw new ExitGUIException();
        }
        else if (canoe.isOptiTrack() && !CC_INPUT.IsOptiTrackInput(resetButton))
        {
            if (!CC_INPUT.IsEnumSeparator(resetButton))
            {
                if (!CC_INPUT.IsOptiTrackInput(validResetButton))
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not OptiTrack input. Defaulting to \"X\" button.");
                    resetButton = navTarget.resetButton = WandButton.X;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not OptiTrack input.");
                    resetButton = navTarget.resetButton = validResetButton;
                }
            }
            throw new ExitGUIException();
        }
        else
        {
            navTarget.resetButton = resetButton;
        }
        //Button logic end

        navTarget.resetSpeed    = resetSpeed;
        navTarget.resetPosition = resetPosition;
        navTarget.resetRotation = resetRotation;
        //RESET ENDS

        //MISC STARTS
        navTarget.cursor = cursor;
        //MISC ENDS
    }
コード例 #22
0
    void Update()
    {
        //Set grab setting
        grab = false;
        if (enableGrabbing)
        {
            if (grabWithTrigger)
            {
                if (CC_INPUT.GetAxis(wand, WandAxis.Trigger) > 0.0f)
                {
                    grab = true;
                }
                else
                {
                    grab = false;
                }
            }
            else
            {
                grab = CC_INPUT.GetButtonPress(wand, grabButton);
            }
        }

        if (grab)
        {
            if (grabbedObject == null)
            {
                if (currentObject != null)
                {
                    grabbedObject = currentObject;
                    // If object had a rigidbody, grabbed save the rigidbody's kinematic state
                    // so it can be restored on release of the object
                    Rigidbody body = null;
                    body = grabbedObject.GetComponent <Rigidbody>();
                    if (body != null)
                    {
                        wasKinematic     = body.isKinematic;
                        body.isKinematic = true;
                    }

                    // Save away to original parentage of the grabbed object
                    grabbedObjectParent = grabbedObject.transform.parent;

                    // Make the grabbed object a child of the wand
                    grabbedObject.transform.parent = CC_CANOE.WandGameObject(wand).transform;
                    currentObject = null;

                    // Disable collision between yourself and the grabbed object so that the grabbed object
                    // does not apply its physics to you and push you off the world
                    Physics.IgnoreCollision(CC_CANOE.CanoeCharacterController(), grabbedObject.GetComponent <Collider>(), true);
                }
            }
        }
        else
        {
            if (grabbedObject != null)
            {
                // Restore the original parentage of the grabbed object
                grabbedObject.transform.parent = grabbedObjectParent;

                // If object had a rigidbody, restore its kinematic state
                Rigidbody body = null;
                body = grabbedObject.GetComponent <Rigidbody>();
                if (body != null)
                {
                    body.isKinematic = wasKinematic;
                }

                //Re-enstate collision between self and object
                Physics.IgnoreCollision(CC_CANOE.CanoeCharacterController(), grabbedObject.GetComponent <Collider>(), false);

                grabbedObject = null;
                currentObject = null;
            }
        }
    }
コード例 #23
0
 void Start()
 {
     //Get the character controller from CC_CANOE.
     charCont = CC_CANOE.CanoeCharacterController();
 }
コード例 #24
0
    public override void OnInspectorGUI()
    {
        //Get This Target
        canoeTarget = (CC_CANOE)target;
        //Disconnect the CC_CANOE prefab instance from the original prefab
        bool isPrefabOriginal = (PrefabUtility.GetPrefabParent(target) == null) && (PrefabUtility.GetPrefabObject(target) != null);

        if (!isPrefabOriginal)
        {
            PrefabUtility.DisconnectPrefabInstance(target);
        }

        EditorGUI.BeginChangeCheck();

        //TRACKING STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Tracking Settings", EditorStyles.boldLabel);
        bool vive      = EditorGUILayout.Toggle(new GUIContent("Vive Tracking", "Use the HTC Vive tracking system."), canoeTarget.vive);
        bool optitrack = EditorGUILayout.Toggle(new GUIContent("OptiTrack Tracking", "Use the OptiTrack tracking system."), canoeTarget.optitrack);

        //TRACKING ENDS

        //CAMERA STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Camera Settings", EditorStyles.boldLabel);
        selCamera       = (CC_CAMERA.SelectedCamera)EditorGUILayout.EnumPopup(new GUIContent("Selected Camera", "Select which camera to use. Keyboard Shortcut: 'P'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().selectCamera);
        enableStereo    = EditorGUILayout.Toggle(new GUIContent("Enable Stereo", "Enable/Disable stereoscopic. Keyboard Shortcut: '9'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().enableStereo);
        interaxial      = EditorGUILayout.IntField(new GUIContent("Interaxial", "Interaxial distance in millimeters.Keyboard Shortcut: '-' and '+'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().interaxial);
        destCameraIndex = (int)EditorGUILayout.Slider(new GUIContent("Destiny Camera Index", "Change the view to different cameras of Destiny. Keyboard Shortcut: '[' and ']'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().destinyCameraIndex, 0, 7);
        float cameraForwartTilt = EditorGUILayout.Slider(new GUIContent("Camera Forward Tilt", "Change the foward tilt of the camera."), canoeTarget.cameraForwardTilt, -90f, 90f);

        //CAMERA ENDS

        //WANDS STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Wand Settings", EditorStyles.boldLabel);
        Wand simulatorActiveWand = (Wand)EditorGUILayout.EnumPopup(new GUIContent("Selected Wand", "The currently active simulator wand."), canoeTarget.simulatorActiveWand);

        CC_CANOE.WandModel wandModel = (CC_CANOE.WandModel)EditorGUILayout.EnumPopup(new GUIContent("Wand Model", "The wand model you wish to be visible. Keyboard Shortcut: '5'"), canoeTarget.wandModel);
        if (canoeTarget.isVive())
        {
            dpadType         = (DpadType)EditorGUILayout.EnumPopup(new GUIContent("Dpad Type", "The Dpad configuration (4 directions or 8 directions) you wish to use."), canoeTarget.dpadType);
            centerClickRange = EditorGUILayout.Slider(new GUIContent("Center Click Range", "Change the range of the Dpad center click."), canoeTarget.centerClickRange, 0.1f, 0.9f);
        }
        //WAND ENDS

        //SIM NAV STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Simulator Navigation Settings", EditorStyles.boldLabel);
        float navigationSpeed         = EditorGUILayout.FloatField(new GUIContent("Movement Speed", "Navigation speed of the simulator controls. (Only affects WASD key movement)"), canoeTarget.navigationSpeed);
        float navigationRotationSpeed = EditorGUILayout.FloatField(new GUIContent("Rotational Speed", "Rotational speed of the simulator controls. (Only affects WASD key movement)"), canoeTarget.navigationRotationSpeed);

        //SIM NAV ENDS

        //MISC STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Misc Settings", EditorStyles.boldLabel);
        CC_CANOE.ShowScreen showScreen = (CC_CANOE.ShowScreen)EditorGUILayout.EnumPopup(new GUIContent("Show Screen", "Enable/Disable the visibility of the CyberCANOE's Screens. Typically you want this set to none unless you are debugging in the editor. Keyboard Shortcut: '6'"), canoeTarget.showScreen);
        bool applyGravity = EditorGUILayout.Toggle(new GUIContent("Apply Gravity", "Enable or disable gravity the Canoe/Player experiences. Does not affect other objects in the scene."), canoeTarget.applyGravity);
        bool kbcont       = EditorGUILayout.Toggle(new GUIContent("Keyboard Controls", "Enable or disable the keyboard controls. This affects the simualtor, camera, and canoe controls."), canoeTarget.kbcont);

        //MISC ENDS

        EditorGUI.EndChangeCheck();

        GUILayout.Space(20);
        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.fontSize  = 12;
        style.fontStyle = FontStyle.Bold;

        if (GUI.changed)
        {
            try {
                Undo.RecordObject(canoeTarget, "Updated Canoe Settings");
                //TRACKING STARTS
                if (vive && !canoeTarget.vive)
                {
                    canoeTarget.vive      = true;
                    canoeTarget.optitrack = false;
                }
                else if (optitrack && !canoeTarget.optitrack)
                {
                    canoeTarget.vive      = false;
                    canoeTarget.optitrack = true;
                }
                //TRACKING ENDS

                //CAMERA STARTS
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().selectCamera       = selCamera;
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().enableStereo       = enableStereo;
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().destinyCameraIndex = destCameraIndex;
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().interaxial         = interaxial;
                canoeTarget.cameraForwardTilt = cameraForwartTilt;
                //CAMERA ENDS

                //WAND STARTS
                canoeTarget.simulatorActiveWand = simulatorActiveWand;
                canoeTarget.wandModel           = wandModel;
                canoeTarget.dpadType            = dpadType;
                canoeTarget.centerClickRange    = centerClickRange;
                //WAND ENDS

                //SIM NAV STARTS
                canoeTarget.navigationSpeed         = navigationSpeed;
                canoeTarget.navigationRotationSpeed = navigationRotationSpeed;
                //SIM NAV ENDS

                //MISC STARTS
                canoeTarget.showScreen   = showScreen;
                canoeTarget.applyGravity = applyGravity;
                canoeTarget.kbcont       = kbcont;
                //MISC ENDS
            }
            catch (System.NullReferenceException) {
                Debug.Log("CC_HEAD can't be found. CC_HEAD should be a child of CC_CANOE.");
            }
        }
    }
コード例 #25
0
    void FixedUpdate()
    {
        if (!enableNavigation)
        {
            return;
        }

        //Save wand model
        savedWandModel = canoe.wandModel;

        //If we are using the trigger button to navigate check if it is pressed.
        if (navWithTrigger)
        {
            if (CC_INPUT.GetAxis(wandToUse, WandAxis.Trigger) > 0.0f)
            {
                doNav         = true;
                endNavUpdated = false;
            }
            else
            {
                doNav = false;
            }
        }
        else
        {
            //Otherwise check the chosen wand button
            doNav         = CC_INPUT.GetButtonPress(wandToUse, navButton);
            endNavUpdated = false;
        }

        if ((resetButton == navButton) && (!navWithTrigger))
        {
            print("CCaux_OmniNavigator Warning: Chosen Navigation and Reset Navigation buttons are the same.");
        }

        //Gradually resets canoe position and rotation
        if (CC_INPUT.GetButtonPress(wandToUse, resetButton))
        {
            charCont.transform.position = Vector3.Slerp(charCont.transform.position, resetPosition, resetSpeed * Time.deltaTime);
            charCont.transform.rotation = Quaternion.Slerp(charCont.transform.rotation, resetAngle, resetSpeed * Time.deltaTime);
        }

        //Disables the cursor and re-enables the wand models ONCE
        if (!doNav && !endNavUpdated)
        {
            doneNav         = false;
            canoe.wandModel = savedWandModel;
            cursor.SetActive(false);
            canoe.UpdateWandModels();
            endNavUpdated = true;
        }

        if (doNav)
        {
            // If wand button pressed the first time then record the starting position and orientation of the wand
            if (doneNav == false)
            {
                startPosition = CC_CANOE.WandGameObject(wandToUse).transform.localPosition;

                doneNav       = true;
                startRotation = CC_CANOE.WandGameObject(wandToUse).transform.localRotation;
            }
            else
            {
                // Then at each time check the difference between new and old wand position as well as new and old wand orientation.
                // Apply that difference to the character controller to effect navigation.
                Vector3 movement = CC_CANOE.WandGameObject(wandToUse).transform.localPosition - startPosition;

                // If disable navigation in a particular axis is enabled then set movement values to zero.
                if (disableNavigationX)
                {
                    movement.x = 0;
                }
                if (disableNavigationY)
                {
                    movement.y = 0;
                }
                if (disableNavigationZ)
                {
                    movement.z = 0;
                }

                movement = gameObject.transform.localRotation * movement; // Movement must take into account current orientation of CyberCANOE

                charCont.Move(movement * Time.deltaTime * moveSpeed);

                Quaternion newRotation = CC_CANOE.WandGameObject(wandToUse).transform.localRotation;

                // Check if a rotation lock is enabled and handle it
                float      axisLockAngle;
                Quaternion rotator = new Quaternion();

                switch (lockRotation)
                {
                case rotationLock.X:
                    axisLockAngle             = newRotation.eulerAngles.x;
                    rotator.eulerAngles       = new Vector3(axisLockAngle, 0, 0);
                    startRotation.eulerAngles = new Vector3(startRotation.eulerAngles.x, 0, 0);
                    break;

                case rotationLock.Y:
                    axisLockAngle             = newRotation.eulerAngles.y;
                    rotator.eulerAngles       = new Vector3(0, axisLockAngle, 0);
                    startRotation.eulerAngles = new Vector3(0, startRotation.eulerAngles.y, 0);
                    break;

                case rotationLock.Z:
                    axisLockAngle             = newRotation.eulerAngles.z;
                    rotator.eulerAngles       = new Vector3(0, 0, axisLockAngle);
                    startRotation.eulerAngles = new Vector3(0, 0, startRotation.eulerAngles.z);
                    break;

                default:
                    rotator = newRotation;
                    break;
                }

                charCont.transform.localRotation = charCont.transform.localRotation * Quaternion.Slerp(Quaternion.identity, Quaternion.Inverse(startRotation * Quaternion.Inverse(rotator)), Time.deltaTime * rotateSpeed);

                // If there is a cursor object then orient it with the wand position.
                if (cursor)
                {
                    cursor.SetActive(true);
                    cursor.transform.position = CC_CANOE.WandGameObject(wandToUse).transform.position;
                    cursor.transform.rotation = CC_CANOE.WandGameObject(wandToUse).transform.rotation;
                    canoe.DeactivateModels();
                }
            }
        }
    }
コード例 #26
0
 void Start()
 {
     charCont   = CC_CANOE.CanoeCharacterController();
     resetAngle = Quaternion.Euler(resetRotation);
     canoe      = gameObject.GetComponent <CC_CANOE>();
 }