コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (gameManager.GameStarted)
        {
            Wand wand = FindObjectOfType <Wand>();
            if (castMagic.GetStateDown(SteamVR_Input_Sources.RightHand))
            {
                GameObject go = new GameObject();
                currLine                   = go.AddComponent <LineRenderer>();
                currLine.startWidth        = 0.05f;
                currLine.endWidth          = 0.05f;
                currLine.material          = lineMat;
                currLine.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                audioSource.clip           = pressClip;
                audioSource.Play();

                //talk to logan's wand

                wand.StartCasting();

                numClicks = 0;
            }
            else if (castMagic.GetLastStateUp(SteamVR_Input_Sources.Any))
            {
                wand.StopCasting();

                //audioSource.clip = releaseClip;
                //audioSource.Play();
            }
            else if (castMagic.GetState(SteamVR_Input_Sources.RightHand))
            {
                GameObject magic = Instantiate(particleMagic, spawnPoint.transform.position, Quaternion.identity);
                magic.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                if (currLine == null)
                {
                    return;
                }
                currLine.positionCount = numClicks + 1;
                currLine.SetPosition(numClicks, spawnPoint.transform.position);
                numClicks++;
            }
        }
        else
        {
            if (castMagic.GetStateDown(SteamVR_Input_Sources.Any))
            {
                audioSource.clip = magicBlast;
                audioSource.Play();
                GameObject magic = Instantiate(particleBlast, spawnPoint.transform.position, Quaternion.identity);
                magic.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
                magic.GetComponent <Rigidbody>().AddForce(transform.up * 350);
            }
        }
    }