Exemplo n.º 1
0
    private void ExtendTentacle()
    {
        audioSource = GetComponent <AudioSource>();
        AudioClip attackSound = stretchAttackSounds[Random.Range(0, stretchAttackSounds.Length)];

        audioSource.PlayOneShot(attackSound);

        // Tentacle will point in direction that the controller is pointing.
        Vector3 reachDirection = Vector3.Normalize(transform.forward);

        //Debug.Log("ButtonTrigger extending tentacle");
        tentacle.OnPlayerStretchMortion(transform, reachDirection);
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     // For testing without a VR system
     if (Input.GetKeyDown("1"))
     {
         leftTentacle.OnPlayerStretchMortion(vrSimulatorLeftHand.transform, vrSimulatorRightHand.transform.forward);
     }
     if (Input.GetKeyDown("2"))
     {
         leftTentacle.OnPlayerShrinkMortion();
     }
     if (Input.GetKeyDown("3"))
     {
         rightTentacle.OnPlayerStretchMortion(vrSimulatorRightHand.transform, vrSimulatorRightHand.transform.forward);
     }
     if (Input.GetKeyDown("4"))
     {
         rightTentacle.OnPlayerShrinkMortion();
     }
 }
Exemplo n.º 3
0
    // Extend tentacle
    // Triggered when player reaches far enough out to cross the surface of the
    // capsule collider around the player.
    void OnTriggerExit(Collider collider)
    {
        // Trigger events are only sent if one of the Colliders also has a Rigidbody attached. Kinematic is OK

        extendedAtLeastOnce = true;

        audioSource = GetComponent <AudioSource>();
        AudioClip attackSound = stretchAttackSounds[Random.Range(0, stretchAttackSounds.Length)];

        audioSource.PlayOneShot(attackSound);

        // Original approach:
        //
        // Find direction of reach using a ROUGH GUESS of where the player's body center is.
        // - This is a flawed approach because the player may be reaching in an arc that
        //   starts somewhere other than their body center.
        // - We are only making a crude guess where the body center is.
        // Vector3 controllerCenter = collider.bounds.center;
        // Vector3 reachDirection = Vector3.Normalize(controllerCenter - playerBody.transform.position);

        // Reach direction = direction controller is pointing
        Vector3 reachDirection = Vector3.Normalize(collider.transform.forward);

        // TENTACLES UP BUG: interesting to see what happens if we force this
        //reachDirection = new Vector3(0.3f, 0.0f, 0.3f);

        Tentacle tentacle = getTentacle(collider);

        if (tentacle != null)
        {
            //print("GestureTrigger TriggerExit reaching in direction: " + reachDirection +
            //    " for object name " + collider.name + " with tag " + collider.tag);
            //DebugDrawLine(collider.gameObject.transform.position,
            //    collider.gameObject.transform.position + reachDirection, Color.red, 3f);

            tentacle.OnPlayerStretchMortion(collider.gameObject.transform, reachDirection);
        }
    }