Esempio n. 1
0
    void Update()
    {
        if (player == null)
        {
            player = GameObject.Find(PhotonNetwork.player.NickName);
        }

        if (isRightFlying && isLeftFlying)
        {
            /*if (Vector3.Distance(player.transform.position, (this.leftLoc + this.rightLoc)/2) > 2f)
             *  velocity = (((this.leftLoc + this.rightLoc) / 2) - player.transform.position).normalized * 10f;
             * else
             *  velocity = (((this.leftLoc + this.rightLoc) / 2) - player.transform.position);*/

            bp.ApplyBodyVelocity(getVelocity(((this.leftLoc + this.rightLoc) / 2)), true, true);
        }
        else if (isRightFlying)
        {
            /*bp.ApplyBodyVelocity((this.rightLoc - player.transform.position) , true, true);
             * if (Vector3.Distance(player.transform.position, this.rightLoc) > 2f)
             *  velocity = (this.rightLoc - player.transform.position).normalized * 10f;
             * else
             *  velocity = (this.rightLoc - player.transform.position);*/
            bp.ApplyBodyVelocity(getVelocity(this.rightLoc), true, true);
        }
        else if (isLeftFlying)
        {
            /*if (Vector3.Distance(player.transform.position, this.rightLoc) > 2f)
             *  velocity = (this.leftLoc - player.transform.position).normalized * 10f;
             * else
             *  velocity = (this.leftLoc - player.transform.position);*/
            bp.ApplyBodyVelocity(getVelocity(this.leftLoc), true, true);
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        isSmokePlaying = smokeTrail.isPlaying;
        isSoundPlaying = sounds[3].isPlaying;

        if (GetComponent <VRTK_ControllerEvents>().touchpadPressed)
        {
            Debug.Log("BURST " + isSmokePlaying + " - " + isSoundPlaying);
            if (!isSmokePlaying)
            {
                smokeTrail.Play();
            }
            if (!isSoundPlaying)
            {
                sounds[3].Play();
            }

            camera = VRTK_DeviceFinder.HeadsetCamera();

            bp.ApplyBodyVelocity(camera.forward * speed, true, true);
        }
        else if (isSoundPlaying || isSmokePlaying)
        {
            Debug.Log(isSmokePlaying + " - " + isSoundPlaying);
            if (!isSoundPlaying)
            {
                sounds[3].Stop();
            }
            if (isSmokePlaying)
            {
                smokeTrail.Stop();
            }
        }
    }
Esempio n. 3
0
    protected virtual void Release(GameObject actualController)
    {
        if (actualController == mPullingController)
        {
            BodyPhysics.ResetFalling();
            mIsPulling = false;

            // Jumping
            Vector3 jumpVector = -mPullingVelocity;
            if (BodyPhysics.OnGround())
            {
                if (jumpVector.y > JumpYThreshold)
                {
                    BodyPhysics.ApplyBodyVelocity(jumpVector * JumpForceFactor, true, true);
                }
            }

            mPullingController = null;
        }
    }
Esempio n. 4
0
    private void StateIteration()
    {
        switch (flightState)
        {
        case FlightState.Flying:

            playerRigidbody.drag = airDrag;
            if (!MovingHandsDown())
            {
                Fly(handsMovingUp: true);
                soundReady = true;
            }
            if (IsFlappingUp())
            {
                FlightSound();
                Fly();
            }

            break;

        case FlightState.Gliding:
            VRTK_bodyPhysics.TogglePreventSnapToFloor(false);
            timeGliding += Time.deltaTime;
            if (GlidingLongEnoughForWind() && audioManager)
            {
                audioManager.PlayWind();
            }
            playerRigidbody.drag = airDrag;
            Glide();
            break;

        case FlightState.Falling:
            playerRigidbody.drag = 0;

            if (!canGlideBackwards && ControllerRotatedBackwards())
            {
            }
            else
            {
                Vector3 currentDirection = XZOnlyNormalized(averageControllerDirection);
                AdjustXZDirection(XZOnlyNormalized(currentDirection));
            }


            break;

        case FlightState.Ground:
            FlightOff();
            return;
        }

        VRTK_bodyPhysics.ApplyBodyVelocity(Vector3.zero, applyMomentum: true);
    }