private void SetWalk()
        {
            var newValue = 0f;

            switch (walkSpeedChangeType)
            {
            case 0: {
                newValue = walkSpeed;
                break;
            }

            case 1: {
                newValue = player.GetWalkSpeed() + walkSpeed;
                break;
            }

            case 2: {
                newValue = Mathf.Clamp(player.GetWalkSpeed() - walkSpeed, Mathf.Epsilon, float.MaxValue);
                break;
            }
            }
            player.SetWalkSpeed(newValue);
        }
示例#2
0
    public void Move2UpDownByUserInput()
    {
        var down = Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.LeftControl);
        var up   = Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.Space);

        if (!down && !up)
        {
            return;
        }
        var s = p.GetWalkSpeed() * Time.deltaTime * Mathf.Max(drag, 1); // cancel drag effect

        if (down)
        {
            velocity += s * Vector3.down;
        }
        if (up)
        {
            velocity += s * Vector3.up;
        }
    }
    public void constupdate()
    {
        ismaster.text        = "ismaster: " + PlayerApiref.isMaster.ToString();
        playerid.text        = "playerid: " + PlayerApiref.playerId.ToString();
        playergrounded.text  = "isplayergrounded: " + PlayerApiref.IsPlayerGrounded().ToString();
        isowner.text         = "isowner: " + PlayerApiref.IsOwner(ownercheck).ToString();
        gravitystrength.text = "gravitystrength: " + PlayerApiref.GetGravityStrength().ToString();
        if (!changeapi)
        {
            runspeed.text    = "runspeed: " + PlayerApiref.GetRunSpeed().ToString();
            walkspeed.text   = "walkspeed: " + PlayerApiref.GetWalkSpeed().ToString();
            jumpimpulse.text = "jumpimpulse: " + PlayerApiref.GetJumpImpulse().ToString();
        }
        else
        {
            runspeed.text    = "runspeed: NULL";
            walkspeed.text   = "walkspeed: NULL";
            jumpimpulse.text = "jumpimpulse: NULL";
        }

        velocity.text = "velocity: " + PlayerApiref.GetVelocity().ToString();
        position.text = "position: " + PlayerApiref.GetPosition().ToString();
        rotation.text = "rotation: " + PlayerApiref.GetRotation().ToString();
    }
示例#4
0
        private bool TestPlayerLocomotionSettings(VRCPlayerApi player)
        {
            Debug.Log("TestPlayerLocomotionSettings");

            // Teleports
            Debug.Log("Player TeleportTo");
            player.TeleportTo(transform.position, Quaternion.identity);

            float expected = 200;
            float val      = 0;

            if (player.isLocal)
            {
                // Strafe
                Debug.Log("Player Strafe: " + player.GetStrafeSpeed());
                player.SetStrafeSpeed(expected);
                val = player.GetStrafeSpeed();
                if (val != expected)
                {
                    Debug.LogError("Strafe speed does not equal expected value!");
                    return(false);
                }
            }

            if (player.isLocal)
            {
                // Walk
                Debug.Log("Player Walk");
                player.SetWalkSpeed(expected);
                val = player.GetWalkSpeed();
                if (val != expected)
                {
                    Debug.LogError("Walk speed does not equal expected value!");
                    return(false);
                }
            }

            if (player.isLocal)
            {
                // Run
                Debug.Log("Player Run");
                player.SetRunSpeed(expected);
                val = player.GetRunSpeed();
                if (val != expected)
                {
                    Debug.LogError("Run speed does not equal expected value!");
                    return(false);
                }
            }

            if (player.isLocal)
            {
                // Jump
                Debug.Log("Player Jump");
                player.SetJumpImpulse(expected);
                val = player.GetJumpImpulse();
                if (val != expected)
                {
                    Debug.LogError("Jump speed does not equal expected value!");
                    return(false);
                }
            }

            if (player.isLocal)
            {
                Debug.Log("Player Gravity");
                player.SetGravityStrength(expected);
                val = player.GetGravityStrength();
                if (val != expected)
                {
                    Debug.LogError("Gravity strength does not equal expected value!");
                    return(false);
                }
            }

            {
                Debug.Log("Player Velocity: " + player.GetVelocity());
                Vector3 velocityExpected = Vector3.up * 50;
                player.SetVelocity(velocityExpected);
                // TODO fix
                // Vector3 velocityActual = player.GetVelocity();
                // if (velocityActual != velocityExpected)
                // {
                //     Debug.LogError("Player velocity does not equal expected value! " +velocityActual +" " + velocityExpected);
                //     return false;
                // }
            }

            {
                Debug.Log("Player IsPlayerGrounded: " + player.IsPlayerGrounded());
            }

            return(true);
        }