コード例 #1
0
    public bool isGrabbed;     //Check if this object is grabbed. Needed for joystick snap-back
                               //Variables dictating how much the controlled object moves

    // Use this for initialization
    void Start()
    {
        isGrabbed = false;

        controller1Script        = theHand1.GetComponent <ControllerGrabObject>();
        controller2Script        = theHand2.GetComponent <ControllerGrabObject>();
        joystickStartPointScript = theJoystickStartPoint.GetComponent <JoystickStartTest>();

        rb = GetComponent <Rigidbody>();
        rb.freezeRotation  = true;
        startPosOfJoystick = transform.position;
        subCraftPosition   = theSubCraft.transform.position;


        minY = startPosOfJoystick.y;
        maxY = startPosOfJoystick.y;



        StartMin = new Vector3(minX, minY, minZ);
        StartMax = new Vector3(maxX, maxY, maxZ);

        minX = startPosOfJoystick.x - tolerance;
        maxX = startPosOfJoystick.x + tolerance;

        minZ = startPosOfJoystick.z - tolerance;
        maxZ = startPosOfJoystick.z + tolerance;

        currentPos = transform.position;



        //Position relative to sub craft
        //posToSubCraft = new Vector3(startPosOfJoystick.x - subCraftPosition.x, startPosOfJoystick.y - subCraftPosition.y, startPosOfJoystick.z - subCraftPosition.z);
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        pingPongSphereCollider = GetComponent <SphereCollider>();
        //LeftHand = GameObject.FindWithTag("LeftHand");

        CGO = LeftHand.GetComponent <ControllerGrabObject>();
    }
コード例 #3
0
    void ShowInventory()
    {
        ControllerGrabObject cont = GetComponent <ControllerGrabObject>();

        cont.ReleaseObject();

        shownToSlot = new Dictionary <GameObject, InventorySlot>();
        foreach (InventorySlot slot in inventory)
        {
            slot.slot.SetActive(true);
            if (slot.content == null)
            {
                continue;
            }
            GameObject prefab = slot.content;
            GameObject inst   = Instantiate(prefab);
            inst.transform.parent = this.transform;
            inst.SetActive(true);

            inst.GetComponent <Rigidbody>().isKinematic = true;
            inst.GetComponent <Rigidbody>().useGravity  = false;
            inst.layer = LayerMask.NameToLayer("Inventory Items");
            inst.transform.position    = slot.slot.transform.position;
            inst.transform.localScale *= objScale / inst.GetComponent <Renderer>().bounds.size.magnitude;
            inst.tag   = "InventoryItem";
            slot.shown = inst;
            shownToSlot.Add(inst, slot);
        }

        shown = true;
    }
コード例 #4
0
 void Awake()
 {
     if (ControllerGrabObject.Getinstance == null)
     {
         ControllerGrabObject.Getinstance = this;
     }
     trackedObj = GetComponent <SteamVR_TrackedObject>();
 }
コード例 #5
0
    public void OnTriggerEnter(Collider other)
    {
        ControllerGrabObject controller = other.GetComponent <ControllerGrabObject>();

        if (controller != null && water.WaterIsRising && hadPunishmentOnce == false)
        {
            hadPunishmentOnce = true;
            water.IncreaseWater();
        }
    }
コード例 #6
0
    void Awake()
    {
        trackedObj = GetComponent <SteamVR_TrackedObject>();
        cgo        = this.GetComponent <ControllerGrabObject>();
        Scene scene = SceneManager.GetActiveScene();

        if (scene.name == "ObstacleCourse")
        {
            OBS = Course.GetComponent <ObstacleCourseSetup>();
        }
    }
コード例 #7
0
    private void Start()
    {
        // make sure current index is 0
        currMenuIndex = 0;

        // we disable all the colliders on the menu objects
        foreach (RubeObject o in objects)
        {
            ControllerGrabObject.ToggleColliders(o.menuPlaceholder, false);
        }

        // set the text
        SetUIText(objects[currMenuIndex].name, objects[currMenuIndex].count);

        // make sure the object menu spawns a little forward of the controller
        objectMenuUI.transform.localPosition = new Vector3(0f, 0f, 0.65f);
    }
コード例 #8
0
    // this function is used to spawn the object that is being shown on the menu (if active)
    private void SpawnCurrentMenuObject()
    {
        // check that we can spawn specific item
        if (objects[currMenuIndex].count > 0)
        {
            // Instantiate the prefab
            GameObject go = Instantiate(objects[currMenuIndex].prefab, objectMenuUI.transform.position, objectMenuUI.transform.rotation);

            // turn on the colliders
            ControllerGrabObject.ToggleColliders(go, true);

            // decrement the count
            objects[currMenuIndex].count--;

            // set the text
            SetUIText(objects[currMenuIndex].name, objects[currMenuIndex].count);
        }
    }
コード例 #9
0
    public void OnTriggerEnter(Collider other)
    {
        ControllerGrabObject controller = other.GetComponent <ControllerGrabObject>();

        if (controller != null && water.WaterIsRising)
        {
            silverKey.SetActive(true);
            Debug.Log(silverKeySpawnpoint.transform.position);
            //moves the silverKey to the spawnpoint position
            silverKey.transform.position = silverKeySpawnpoint.transform.position;
        }

        /*
         * if (controller != null && water.WaterIsRising && controller.triggerPressed)
         * {
         *  silverKey.SetActive(true);
         *  Debug.Log(silverKeySpawnpoint.transform.position);
         *  //moves the silverKey to the spawnpoint position
         *  silverKey.transform.position = silverKeySpawnpoint.transform.position;
         * }*/
    }
 void Awake()
 {
     trackedObj = GetComponent <SteamVR_TrackedObject>();
     cgo        = this.GetComponent <ControllerGrabObject>();
 }
コード例 #11
0
 private void Start()
 {
     controllerGrabObject = gameObject.GetComponent <ControllerGrabObject>();
 }
コード例 #12
0
 void Start()
 {
     menuController = FindObjectOfType <MenuController>();
     grabber        = GetComponent <ControllerGrabObject>();
 }
コード例 #13
0
 void Start()
 {
     menu = leftController.GetComponent <Menu>();
     cGOL = leftController.GetComponent <ControllerGrabObject>();
     cGOR = rightController.GetComponent <ControllerGrabObject>();
 }