Exemplo n.º 1
0
    private void Update()
    {
        if (PlayerApiref != null)
        {
            if (state)
            {
                Vector3 player = PlayerApiref.GetPosition();

                if (Vector3.Distance(player, teleport_entry.position) < teleport_radius)
                {
                    if (twoway_ref != null)
                    {
                        twoway_ref.SetProgramVariable("state", false);
                    }
                    PlayerApiref.TeleportTo(teleport_receiver.position, teleport_receiver.rotation);
                }
            }
            else
            {
                Vector3 player = PlayerApiref.GetPosition();

                if (Vector3.Distance(player, teleport_entry.position) > teleport_radius)
                {
                    state = true;
                }
            }
        }
    }
Exemplo n.º 2
0
        public void ResetOffsets()
        {
            offsetPos = Vector3.zero;
            oldRot    = 0;
            offsetRot = 0;
            var targetPos = player.GetPosition();
            var targetRot = player.GetRotation();

            targetTransform.SetPositionAndRotation(targetPos, targetRot);
        }
Exemplo n.º 3
0
    /// <summary>
    /// Calculates distance to the closest ground collider
    /// </summary>
    /// <returns>Distance to ground</returns>
    private float GetGroundDistance()
    {
        var        groundRayDirection = Vector3.down;
        var        playerBase         = player.GetPosition();
        RaycastHit hit;

        if (Physics.Raycast(playerBase, groundRayDirection, out hit, 200f, groundLayers))
        {
            return(hit.distance);
        }
        return(200f);
    }
Exemplo n.º 4
0
        public override void OnPlayerTriggerEnter(VRCPlayerApi player)
        {
            if (!udonDebug.Assert(Utilities.IsValid(player), "Invalid player entered", this))
            {
                return;
            }

            if (!player.isLocal)
            {
                return;
            }

            _enterPosition = transform.InverseTransformPoint(player.GetPosition() + _playerColliderGroundOffset);

            if (leaveOnTouch)
            {
                if (!udonDebug.Assert(Utilities.IsValid(voiceOverrideRoom), "Failed removing player from override",
                                      this))
                {
                    return;
                }

                if (voiceOverrideRoom.Contains(player))
                {
                    voiceOverrideRoom.ExitRoom(player, null);
                }
            }
        }
Exemplo n.º 5
0
    private void LateUpdate()
    {
        // 追従するプレイヤーのLocalで処理をする
        if (isTracking)
        {
            // 追従オブジェクトと追従するプレイヤーとの場所の差分
            var distance = characterRoot.position - player.GetPosition();

            // ボーンの位置を反映させる
            headPoint.position = player.GetBonePosition(HumanBodyBones.Head) + distance;
            headPoint.rotation = player.GetBoneRotation(HumanBodyBones.Head);

            hipPoint.position = player.GetBonePosition(HumanBodyBones.Hips) + distance;
            hipPoint.rotation = player.GetBoneRotation(HumanBodyBones.Hips);

            lhandPoint.position = player.GetBonePosition(HumanBodyBones.LeftHand) + distance;
            lhandPoint.rotation = player.GetBoneRotation(HumanBodyBones.LeftHand);

            rhandPoint.position = player.GetBonePosition(HumanBodyBones.RightHand) + distance;
            rhandPoint.rotation = player.GetBoneRotation(HumanBodyBones.RightHand);

            lfootPoint.position = player.GetBonePosition(HumanBodyBones.LeftFoot) + distance;
            lfootPoint.rotation = player.GetBoneRotation(HumanBodyBones.LeftFoot);

            rfootPoint.position = player.GetBonePosition(HumanBodyBones.RightFoot) + distance;
            rfootPoint.rotation = player.GetBoneRotation(HumanBodyBones.RightFoot);
        }
    }
    private void Update()
    {
        /*    if (localPlayer.IsOwner(gameObject))
         * { */
        if (menuactive)
        {
            WindStrength      = WindStrengthSlider.value;
            WindStr_text.text = WindStrengthSlider.value.ToString("F1");

            WindGustStrength           = WindGustStrengthSlider.value;
            WindGustStrength_text.text = WindGustStrengthSlider.value.ToString("F1");

            WindGustiness           = WindGustinessSlider.value;
            WindGustiness_text.text = WindGustinessSlider.value.ToString("F3");

            WindTurbulanceScale           = WindTurbulanceScaleSlider.value;
            WindTurbulanceScale_text.text = WindTurbulanceScaleSlider.value.ToString("F5");

            if (Vector3.Distance(transform.position, localPlayer.GetPosition()) > 3)
            {
                WindMenu.SetActive(false);
                menuactive = false;
            }
        }

        /*    }
         * else
         * {
         *     WindStrengthSlider.value = WindStrength;
         *     WindGustStrengthSlider.value = WindGustStrength;
         *     WindGustinessSlider.value = WindGustiness;
         *     WindTurbulanceScaleSlider.value = WindTurbulanceScale;
         * } */
    }
Exemplo n.º 7
0
 public void PreviewNext()
 {
     if (Networking.IsOwner(this.gameObject))
     {
         var          distX      = 0f;
         var          distZ      = 0f;
         VRCPlayerApi player     = null;
         Vector3      playerPos  = new Vector3();
         Vector3      fieldPos   = Sabage.GameField.GetComponent <Transform>().position;
         Vector3      fieldSize  = Sabage.GameField.GetComponent <Transform>().localScale / 2f;
         var          beforeID   = -1;
         var          firstID    = -1;
         var          id         = -1;
         var          trackingID = -1;
         for (int i = 0; i < Sabage.Player_IDs.Length; ++i)
         {
             id = Sabage.Player_IDs[i];
             if (id != -1)
             {
                 player    = VRCPlayerApi.GetPlayerById(id);
                 playerPos = player.GetPosition();
                 distX     = Mathf.Abs(playerPos.x - fieldPos.x);
                 distZ     = Mathf.Abs(playerPos.z - fieldPos.z);
                 if (distX <= fieldSize.x && distZ <= fieldSize.z)
                 {
                     if (firstID == -1)
                     {
                         firstID = player.playerId;
                     }
                     if (beforeID == player.playerId)
                     {
                         trackingID = player.playerId;
                         break;
                     }
                     beforeID = player.playerId;
                 }
             }
         }
         if (trackingID != -1)
         {
             TrackingUserID = trackingID;
         }
         else if (firstID != -1)
         {
             TrackingUserID = firstID;
         }
         else
         {
             TrackingUserID = Networking.LocalPlayer.playerId;
         }
         SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, "UpdateText");
     }
     else
     {
         SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "PreviewNext");
     }
 }
Exemplo n.º 8
0
    private void Update()
    {
        _timeSliceTimer += Time.deltaTime;
        if (_timeSliceTimer < _timeSliceInterval)
        {
            return;
        }

        _timeSliceTimer = 0;

        var t = transform;

        _lastPosition = t.position;

        if (!_isPlayerTracker)
        {
            t.position = _target.position;
        }
        else if (_player != null)
        {
            t.position = _player.GetPosition();
        }
        else
        {
            enabled = false;
            return;
        }

        bool hit = Physics.CheckSphere(t.position, _hitRadius, _layer);

        _emission.enabled = hit;

        if (hit && (t.position - _lastPosition).sqrMagnitude > _minMoveSqrMagnitude)
        {
            AudioSource audioSource;
            if (_lastAudioIndex < _audioSourcesLength)
            {
                int rand = Random.Range(0, _audioSourcesLength - 1);
                if (rand >= _lastAudioIndex)
                {
                    rand++;
                }

                _lastAudioIndex = rand;
                audioSource     = _audioSources[rand];
            }
            else
            {
                _lastAudioIndex = Random.Range(0, _audioSourcesLength);
                audioSource     = _audioSources[Random.Range(0, _audioSourcesLength)];
            }
            if (!audioSource.isPlaying)
            {
                audioSource.Play();
            }
        }
    }
    private void Update()
    {
        if (!Disabled)
        {
            //check for change in target
            if (currenttarget != AAMTarget)
            {
                if (AAMTargets[AAMTarget] != null && AAMTargets[AAMTarget].transform.parent != null)
                {
                    TargetEngine = AAMTargets[AAMTarget].transform.parent.GetComponent <EngineController>();
                    TargetCoM    = TargetEngine.CenterOfMass;
                    PlaneCamera.transform.rotation = TargetEngine.VehicleMainObj.transform.rotation;
                }
            }
            currenttarget = AAMTarget;
            //disable if far away
            if (!InEditor)
            {
                if (Vector3.Distance(localPlayer.GetPosition(), gameObject.transform.position) > DisableDistance)
                {
                    ViewScreen.SetActive(false);
                    PlaneCamera.gameObject.SetActive(false);
                    Disabled = true;
                }
            }
            if (TargetEngine.EffectsControl.LargeEffectsOnly)
            {
                TargetEngine.EffectsControl.Effects();
            }                                         //this is skipped in effectscontroller as an optimization if plane is distant, but the camera can see it close up, so do it here.

            var        VehicleTrans = TargetEngine.VehicleMainObj.transform;
            Quaternion NewRot;
            Vector3    NewPos = VehicleTrans.TransformDirection(new Vector3(0, 14, 0));
            RaycastHit hit;
            if (Physics.Raycast(TargetCoM.position + NewPos, -VehicleTrans.forward, out hit, 50, 1))
            {
                NewPos = hit.point + VehicleTrans.forward * .2f;
                NewRot = VehicleTrans.rotation;
                NewRot = Quaternion.AngleAxis(((-hit.distance + 50) / 50) * 30, VehicleTrans.right) * NewRot;
            }
            else
            {
                NewPos = (TargetCoM.position + NewPos) - (VehicleTrans.forward * 50);
                NewRot = VehicleTrans.rotation;
            }

            PlaneCamera.transform.position = NewPos;
            PlaneCamera.transform.rotation = Quaternion.Slerp(PlaneCamera.transform.rotation, NewRot, 8f * Time.deltaTime);

            ChannelNumberText.text = string.Concat((AAMTarget + 1).ToString(), "\n", TargetEngine.PilotName);
        }
    }
Exemplo n.º 10
0
    bool TooCloseToPound()
    {
        if (_tooCloseToGroundThisFrame == -1)
        {
            Ray        ray = new Ray(player.GetPosition(), Vector3.down);
            RaycastHit hit;
            bool       wasHit = Physics.Raycast(ray, out hit, groundPoundTooCloseDistance, groundMask, QueryTriggerInteraction.UseGlobal);
            distanceToGroundLast       = hit.distance;
            _tooCloseToGroundThisFrame = wasHit ? (sbyte)1 : (sbyte)0;
        }

        return(_tooCloseToGroundThisFrame == 1);
    }
Exemplo n.º 11
0
        public override void OnPlayerTriggerExit(VRCPlayerApi player)
        {
            if (!udonDebug.Assert(Utilities.IsValid(player), "Invalid player left", this))
            {
                return;
            }

            if (!player.isLocal)
            {
                return;
            }

            if (_enterPosition == Vector3.zero)
            {
                return;
            }

            var exitPosition  = transform.InverseTransformPoint(player.GetPosition() + _playerColliderGroundOffset);
            var enterPosition = _enterPosition;

            _enterPosition = Vector3.zero;

            if (HasExited(enterPosition, exitPosition, exitDirection))
            {
                if (!udonDebug.Assert(Utilities.IsValid(voiceOverrideRoom), "Failed removing player from override",
                                      this))
                {
                    return;
                }

                if (voiceOverrideRoom.Contains(player))
                {
                    voiceOverrideRoom.ExitRoom(player, null);
                }
                return;
            }

            var enterDirection = -exitDirection;

            if (HasEntered(enterPosition, exitPosition, enterDirection))
            {
                if (!udonDebug.Assert(Utilities.IsValid(voiceOverrideRoom), "Failed adding player to override",
                                      this))
                {
                    return;
                }

                voiceOverrideRoom.EnterRoom(player, null);
            }
        }
Exemplo n.º 12
0
 private void Start()
 {
     player = Networking.LocalPlayer;
     if (player == null)
     {
         return;
     }
     if (trackPlayspace)
     {
         var targetPos = player.GetPosition();
         var targetRot = player.GetRotation();
         targetTransform.SetPositionAndRotation(targetPos, targetRot);
     }
     isEditor = false;
 }
Exemplo n.º 13
0
    private void TickHealthStatus()
    {
        float hp = float.Parse(player.GetPlayerTag("combat_hp"));

        if (hp < 0)
        {
            Debug.Log($"CombatSystem: {player.displayName} has died!");

            lastPosition = player.GetPosition();

            Debug.Log($"CombatSystem: {player.displayName} is now unable to move.");

            inDeathProcess = true;
        }
    }
Exemplo n.º 14
0
    private void Update()
    {
        if (!_initialized)
        {
            Initialize();
            return;
        }

        var   pos  = _localPlayer.GetPosition() + Vector3.up * _camOffset;
        float size = 1f / _snowCam.orthographicSize;

        _snowCam.transform.position = pos;

        _snowMaterial.SetVector("_TopCamData", new Vector4(pos.x, pos.y, pos.z, size));
    }
Exemplo n.º 15
0
 private void Update()
 {
     var dist = Vector3.Distance(localPlayer.GetPosition(), referencePoint.transform.position);
     if (dist < threshold)
     {
         if (!isActivated)
         {
             isActivated = true;
             localPlayer.SetVelocity(boost.normalized * boostSpeed);
         }
     }
     else if (isActivated)
     {
         isActivated = false;
     }
 }
    private void FixedUpdate()
    {
        VRCPlayerApi p = Networking.LocalPlayer;

        PlayerInfoText.text =
            $"DisplayName: {p.displayName}\n" +
            $"PlayerId: {p.playerId}\n" +
            $"Position: {p.GetPosition()}\n" +
            $"CurHitpoint: {p.GetPlayerTag("combat_hp")}\n" +
            $"MaxHitpoint: {p.GetPlayerTag("combat_max_hp")}\n" +
            $"isGrounded: {p.IsPlayerGrounded()}\n" +
            $"isLocal: {p.isLocal}\n" +
            $"isMaster: {p.isMaster}\n" +
            $"PlayerTestTagValue: {p.GetPlayerTag("test")}\n" +
            $"RespawnTimer: {p.GetPlayerTag("combat_respawn_timer")}\n" +
            $"Id1: {(VRCPlayerApi.GetPlayerById(1) == null ? null : VRCPlayerApi.GetPlayerById(1).displayName)}";
    }
Exemplo n.º 17
0
    private void Update()
    {
        var dist = Vector3.Distance(localPlayer.GetPosition(), referencePoint.transform.position);

        if (dist < range)
        {
            if (!inProx)
            {
                inProx = true;
                ProximityAction();
            }
        }
        else if (inProx)
        {
            inProx = false;
            ExitProxAction();
        }
    }
Exemplo n.º 18
0
    public void Update()
    {
        if (GunActive)
        {
            PlayerCapsule.transform.position = Owner.GetPosition();
        }

        if (OwnershipTimer)
        {
            currentTime += Time.deltaTime;
            if (currentTime >= wantedTime)
            {
                OwnershipTimer = false;
                currentTime    = 0.0f;
                PlayerCapsule.GetComponent <Capsule>().SetTeam();
                OwnerName     = Owner.displayName;
                Ownerbar.text = OwnerName;
            }
        }

        if (Health <= 0f)
        {
            CommitNotAlive();
        }

        if (Reloading)
        {
            currentReloadTime += Time.deltaTime;
            if (currentReloadTime * 2 >= ReloadTime)
            {
                Line.SetPosition(1, LaserOrigin.position);
            }

            if (currentReloadTime >= ReloadTime)
            {
                Reloading         = false;
                currentReloadTime = 0f;
                Audio.PlayOneShot(ReloadClip);
            }
        }

        Healthbar.text = Convert.ToString(Health);
    }
Exemplo n.º 19
0
    public void Play()
    {
        if (isNotInit)
        {
            return;
        }
        VRCPlayerApi player = Networking.GetOwner(gameObject);

        //Update avatar height
        if (Time.time - lastAvatarHeightUpdate > 10)
        {
            avatarHeight           = GetAvatarHeight(player);
            lastAvatarHeightUpdate = Time.time;
            transform.localScale   = Vector3.one * avatarHeight;
            float pitch = -Mathf.Log(avatarHeight * 0.1f) * 0.4f + 0.2f;
            pitch = Mathf.Clamp(pitch, 0.2f, 3f);
            float volume = avatarHeight * 0.3f + 0.5f;
            volume = Mathf.Clamp(volume, 0.5f, 1f);
            float distance = avatarHeight * 2;
            distance                 = Mathf.Clamp(distance, 1, 10);
            _audioSource.pitch       = pitch;
            _audioSource.maxDistance = distance;
            _audioSource.volume      = volume;
            Debug.Log($"[Clapper] Height: {avatarHeight} => pitch: {pitch} => volume: {volume} => distance: {distance}");
        }
        //Set position
        if (player.IsUserInVR())
        {
            transform.position = Vector3.Lerp(player.GetTrackingData(VRCPlayerApi.TrackingDataType.LeftHand).position,
                                              player.GetTrackingData(VRCPlayerApi.TrackingDataType.RightHand).position, 0.5f);
        }
        else
        {
            transform.position = isHumanoid ? player.GetBonePosition(HumanBodyBones.Chest) :
                                 Vector3.Lerp(player.GetPosition(), player.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).position, 0.7f);
        }
        transform.rotation = player.GetRotation();
        //Play particle and audio source
        _particleSystem.Emit(1);
        _audioSource.Play();
    }
Exemplo n.º 20
0
    public float GetAvatarHeight(VRCPlayerApi player)
    {
        float   height     = 0;
        Vector3 postition1 = player.GetBonePosition(HumanBodyBones.Head);
        Vector3 postition2 = player.GetBonePosition(HumanBodyBones.Neck);

        height    += Vector3.Distance(postition1, postition2);
        postition1 = player.GetBonePosition(HumanBodyBones.Hips);
        height    += Vector3.Distance(postition1, postition2);
        isHumanoid = height > 0;
        if (!isHumanoid)
        {
            return(Vector3.Distance(player.GetPosition(), player.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).position) * 1.15f);             //For non humanoids
        }
        postition2 = player.GetBonePosition(HumanBodyBones.RightLowerLeg);
        height    += Vector3.Distance(postition1, postition2);
        postition1 = player.GetBonePosition(HumanBodyBones.RightFoot);
        height    += Vector3.Distance(postition1, postition2);
        height    *= 1.15f; // Adjusting for head
        return(height);
    }
Exemplo n.º 21
0
    public override void OnPlayerTriggerEnter(VRCPlayerApi player)
    {
        if (!active)
        {
            return;
        }

        var vel = player.GetVelocity();


        if (Vector3.Dot(vel, transform.up) <= 0f)
        {
            var playerPos = player.GetPosition();
            var localVel  = transform.worldToLocalMatrix.MultiplyVector(vel);

            localVel.y = -Mathf.Max(Mathf.Abs(localVel.y), pushVelocity);
            vel        = transform.localToWorldMatrix.MultiplyVector(localVel);

            vel = Vector3.Reflect(vel, transform.up);
            player.SetVelocity(vel);
        }
    }
Exemplo n.º 22
0
    private void Update()
    {
        timeSinceLastBlink    += Time.deltaTime;
        timeSinceLastRecharge += Time.deltaTime;

        if (timeSinceLastRecharge > cooldownRecharge)
        {
            charges += refillAmount;
            if (charges > maxCharges)
            {
                charges = maxCharges;
            }

            timeSinceLastRecharge = 0;
        }

        // TODO: Some other button might be better for this but idk which one yet.
        // If jump button is pressed.
        if ((Input.GetButtonDown("Oculus_CrossPlatform_SecondaryThumbstick") || Input.GetButtonDown("Jump")) && timeSinceLastBlink > cooldownBlink && charges > 0)
        {
            blinkDist = maxBlinkDistance;
            // TODO: This may need to be changed to avatar origin position to prevent clipping into ground with tall avatars.
            headPos = playerLocal.GetBonePosition(HumanBodyBones.Head);
            headRot = playerLocal.GetBoneRotation(HumanBodyBones.Head);
            if (Physics.Raycast(headPos, headRot * Vector3.forward, out rayHit))
            {
                if (rayHit.distance <= maxBlinkDistance)
                {
                    blinkDist = rayHit.distance;
                }
            }
            playerLocal.TeleportTo(playerLocal.GetPosition() + (headRot * Vector3.forward) * (blinkDist - destinationDistFromCollider), playerLocal.GetRotation());

            timeSinceLastBlink = 0;
            charges--;
        }
    }
Exemplo n.º 23
0
    private void Update()
    {
        Vector3    playerPosition = playerLocal.GetPosition();
        Quaternion playerRotation = playerLocal.GetRotation();
        Vector3    closestPoint   = platformCollider.ClosestPoint(playerPosition);

        playerRelativeHeight = playerPosition.y - closestPoint.y;
        isAlignedToPlatform  = (playerPosition.x == closestPoint.x) && (playerPosition.z == closestPoint.z);
        if (grabHeight.y <= playerRelativeHeight && playerRelativeHeight <= grabHeight.x && isAlignedToPlatform)
        {
            if (lockedPlayerY <= -10000)
            {
                lockedPlayerY = playerPosition.y;
            }

            // How much has platform moved since last frame?
            Vector3 platformPosDelta = platform.transform.position - platformPosBuffer;

            // Move player the same distance the platform moved
            newPos = playerPosition + platformPosDelta;

            if (lockPlayerY)
            {
                newPos.y = lockedPlayerY;
            }

            playerLocal.TeleportTo(newPos, playerRotation);
        }
        else
        {
            lockedPlayerY = -10001;
        }

        // Set remember pre-move position of platform for next frame
        platformPosBuffer = platform.transform.position;
    }
    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();
    }
Exemplo n.º 25
0
    public void UpdateTrackValue()
    {
        if (trackType == 1)
        {
            VRCPlayerApi player = null;
            switch (targetPlayer)
            {
            case 0:
                player = Networking.LocalPlayer;
                break;

            case 1:
                player = Networking.GetOwner(gameObject);
                break;

            case 2:
                if (targetTrigger)
                {
                    var playerField = (VRCPlayerApi)targetTrigger.GetProgramVariable("triggeredPlayer");
                    player = playerField;
                }
                break;

            case 3:
                VRCPlayerApi[] players = new VRCPlayerApi[VRCPlayerApi.GetPlayerCount()];;
                VRCPlayerApi.GetPlayers(players);
                if (index < players.Length)
                {
                    player = players[index];
                }
                else
                {
                    player = Networking.LocalPlayer;
                }
                break;
            }
            if (player == null || !player.IsValid())
            {
                return;
            }

            switch (spot)
            {
            case "IsUserInVR":
                value_b = player.IsUserInVR();
                break;

            case "IsPlayerGrounded":
                value_b = player.IsPlayerGrounded();
                break;

            case "IsMaster":
                value_b = player.isMaster;
                break;

            case "IsInstanceOwner":
                value_b = player.isInstanceOwner;
                break;

            case "IsGameObjectOwner":
                value_b = player.IsOwner(gameObject);
                break;

            case "Position":
                value_v3 = player.GetPosition();
                if (positionTracking)
                {
                    transform.position = player.GetPosition();
                    transform.rotation = player.GetRotation();
                }
                break;

            case "Rotation":
                value_v3 = player.GetRotation().eulerAngles;
                break;

            case "HeadPosition":
                value_v3 = player.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).position;
                if (positionTracking)
                {
                    transform.position = player.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).position;
                    transform.rotation = player.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).rotation;
                }
                break;

            case "HeadRotation":
                value_v3 = player.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).rotation.eulerAngles;
                break;

            case "RightHandPosition":
                value_v3 = player.GetTrackingData(VRCPlayerApi.TrackingDataType.RightHand).position;
                if (positionTracking)
                {
                    transform.position = player.GetTrackingData(VRCPlayerApi.TrackingDataType.RightHand).position;
                    transform.rotation = player.GetTrackingData(VRCPlayerApi.TrackingDataType.RightHand).rotation;
                }
                break;

            case "RightHandRotation":
                value_v3 = player.GetTrackingData(VRCPlayerApi.TrackingDataType.RightHand).rotation.eulerAngles;
                break;

            case "LeftHandPosition":
                value_v3 = player.GetTrackingData(VRCPlayerApi.TrackingDataType.LeftHand).position;
                if (positionTracking)
                {
                    transform.position = player.GetTrackingData(VRCPlayerApi.TrackingDataType.LeftHand).position;
                    transform.rotation = player.GetTrackingData(VRCPlayerApi.TrackingDataType.LeftHand).rotation;
                }
                break;

            case "LeftHandRotation":
                value_v3 = player.GetTrackingData(VRCPlayerApi.TrackingDataType.LeftHand).rotation.eulerAngles;
                break;

            case "Velocity":
                value_v3 = player.GetVelocity();
                break;

            case "DisplayName":
                value_s = player.displayName;
                break;
            }
        }

        if (trackType == 2)
        {
            if (!targetObject)
            {
                return;
            }

            switch (spot)
            {
            case "IsActive":
                value_b = targetObject.activeSelf;
                break;

            case "Position":
                value_v3 = targetObject.transform.position;
                if (positionTracking)
                {
                    transform.position = targetObject.transform.position;
                    transform.rotation = targetObject.transform.rotation;
                }
                break;

            case "Rotation":
                value_v3 = targetObject.transform.rotation.eulerAngles;
                break;

            case "LocalPosition":
                value_v3 = targetObject.transform.localPosition;
                if (positionTracking)
                {
                    transform.position = targetObject.transform.position;
                    transform.rotation = targetObject.transform.rotation;
                }
                break;

            case "LocalRotation":
                value_v3 = targetObject.transform.localRotation.eulerAngles;
                break;

            case "Velocity":
                value_v3 = targetObject.GetComponent <Rigidbody>().velocity;
                break;

            case "AngularVelocity":
                value_v3 = targetObject.GetComponent <Rigidbody>().angularVelocity;
                break;
            }
        }

        if (trackType == 3)
        {
            switch (spot)
            {
            case "PlayerCount":
                value_i = VRCPlayerApi.GetPlayerCount();
                value_f = value_i;
                break;

            case "Year":
                value_i = System.DateTime.Now.Year;
                value_f = value_i;
                break;

            case "Month":
                value_i = System.DateTime.Now.Month;
                value_f = value_i;
                break;

            case "Day":
                value_i = System.DateTime.Now.Day;
                value_f = value_i;
                break;

            case "DayOfWeek":
                value_i = (int)System.DateTime.Now.DayOfWeek;
                value_f = value_i;
                break;

            case "Hour":
                value_i = System.DateTime.Now.Hour;
                value_f = value_i;
                break;

            case "Minute":
                value_i = System.DateTime.Now.Minute;
                value_f = value_i;
                break;

            case "Second":
                value_i = System.DateTime.Now.Second;
                value_f = value_i;
                break;

            case "JoinHours":
                value_f = (float)(System.DateTime.Now - startTime).TotalHours;
                value_i = (int)value_f;
                break;

            case "JoinMinutes":
                value_f = (float)(System.DateTime.Now - startTime).TotalMinutes;
                value_i = (int)value_f;
                break;

            case "JoinSeconds":
                value_f = (float)(System.DateTime.Now - startTime).TotalSeconds;
                value_i = (int)value_f;
                break;
            }
        }

        if (trackType == 4)
        {
            if (targetComponent)
            {
                if (valueType == 0)
                {
                    if (spot == "Toggle")
                    {
                        var toggle = (Toggle)targetComponent;
                        value_b = toggle.isOn;
                    }
                }
                if (valueType == 1)
                {
                    if (spot == "Text")
                    {
                        var text = (Text)targetComponent;
                        int.TryParse(text.text, out value_i);
                    }
                    if (spot == "InputField")
                    {
                        var inputField = (InputField)targetComponent;
                        int.TryParse(inputField.text, out value_i);
                    }
                }
                if (valueType == 2)
                {
                    if (spot == "Slider")
                    {
                        var slider = (Slider)targetComponent;
                        value_f = slider.value;
                    }
                    if (spot == "Scrollbar")
                    {
                        var scrollbar = (Scrollbar)targetComponent;
                        value_f = scrollbar.value;
                    }
                    if (spot == "Text")
                    {
                        var text = (Text)targetComponent;
                        float.TryParse(text.text, out value_f);
                    }
                    if (spot == "InputField")
                    {
                        var inputField = (InputField)targetComponent;
                        float.TryParse(inputField.text, out value_f);
                    }
                }
                if (valueType == 4)
                {
                    if (spot == "Text")
                    {
                        var text = (Text)targetComponent;
                        value_s = text.text;
                    }
                    if (spot == "InputField")
                    {
                        var inputField = (InputField)targetComponent;
                        value_s = inputField.text;
                    }
                }
            }
        }

        if (trackType == 5)
        {
            if (targetComponent != null && spot != "")
            {
                Animator animator = (Animator)targetComponent;
                if (valueType == 0)
                {
                    value_b = animator.GetBool(spot);
                }
                if (valueType == 1)
                {
                    value_i = animator.GetInteger(spot);
                }
                if (valueType == 2)
                {
                    value_f = animator.GetFloat(spot);
                }
            }
        }

        if (trackType == 6)
        {
            switch (spot)
            {
            case "RightIndexTrigger":
                value_f = Input.GetAxis("Oculus_CrossPlatform_SecondaryIndexTrigger");
                break;

            case "LeftIndexTrigger":
                value_f = Input.GetAxis("Oculus_CrossPlatform_PrimaryIndexTrigger");
                break;

            case "RightGrip":
                value_f = Input.GetAxis("Oculus_CrossPlatform_SecondaryHandTrigger");
                break;

            case "LeftGrip":
                value_f = Input.GetAxis("Oculus_CrossPlatform_PrimaryHandTrigger");
                break;
            }
        }

        UpdateSubValue();
    }
Exemplo n.º 26
0
    private void Update()
    {
        VRCPlayerApi PlayerApiref = Networking.GetOwner(gameObject);

        if (PlayerApiref != null && track)
        {
            transform.position = PlayerApiref.GetPosition();
            transform.rotation = PlayerApiref.GetRotation();
            bonesset(HumanBodyBones.Hips, 0, PlayerApiref);
            bonesset(HumanBodyBones.LeftUpperLeg, 1, PlayerApiref);
            bonesset(HumanBodyBones.RightUpperLeg, 2, PlayerApiref);
            bonesset(HumanBodyBones.LeftLowerLeg, 3, PlayerApiref);
            bonesset(HumanBodyBones.RightLowerLeg, 4, PlayerApiref);
            bonesset(HumanBodyBones.LeftFoot, 5, PlayerApiref);
            bonesset(HumanBodyBones.RightFoot, 6, PlayerApiref);
            bonesset(HumanBodyBones.Spine, 7, PlayerApiref);
            bonesset(HumanBodyBones.Chest, 8, PlayerApiref);
            bonesset(HumanBodyBones.Neck, 9, PlayerApiref);
            bonesset(HumanBodyBones.Head, 10, PlayerApiref);
            bonesset(HumanBodyBones.LeftShoulder, 11, PlayerApiref);
            bonesset(HumanBodyBones.RightShoulder, 12, PlayerApiref);
            bonesset(HumanBodyBones.LeftUpperArm, 13, PlayerApiref);
            bonesset(HumanBodyBones.RightUpperArm, 14, PlayerApiref);
            bonesset(HumanBodyBones.LeftLowerArm, 15, PlayerApiref);
            bonesset(HumanBodyBones.RightLowerArm, 16, PlayerApiref);
            bonesset(HumanBodyBones.LeftHand, 17, PlayerApiref);
            bonesset(HumanBodyBones.RightHand, 18, PlayerApiref);
            bonesset(HumanBodyBones.LeftToes, 19, PlayerApiref);
            bonesset(HumanBodyBones.RightToes, 20, PlayerApiref);
            bonesset(HumanBodyBones.LeftEye, 21, PlayerApiref);
            bonesset(HumanBodyBones.RightEye, 22, PlayerApiref);
            bonesset(HumanBodyBones.Jaw, 23, PlayerApiref);
            bonesset(HumanBodyBones.LeftThumbProximal, 24, PlayerApiref);
            bonesset(HumanBodyBones.LeftThumbIntermediate, 25, PlayerApiref);
            bonesset(HumanBodyBones.LeftThumbDistal, 26, PlayerApiref);
            bonesset(HumanBodyBones.LeftIndexProximal, 27, PlayerApiref);
            bonesset(HumanBodyBones.LeftIndexIntermediate, 28, PlayerApiref);
            bonesset(HumanBodyBones.LeftIndexDistal, 29, PlayerApiref);
            bonesset(HumanBodyBones.LeftMiddleProximal, 30, PlayerApiref);
            bonesset(HumanBodyBones.LeftMiddleIntermediate, 31, PlayerApiref);
            bonesset(HumanBodyBones.LeftMiddleDistal, 32, PlayerApiref);
            bonesset(HumanBodyBones.LeftRingProximal, 33, PlayerApiref);
            bonesset(HumanBodyBones.LeftRingIntermediate, 34, PlayerApiref);
            bonesset(HumanBodyBones.LeftRingDistal, 35, PlayerApiref);
            bonesset(HumanBodyBones.LeftLittleProximal, 36, PlayerApiref);
            bonesset(HumanBodyBones.LeftLittleIntermediate, 37, PlayerApiref);
            bonesset(HumanBodyBones.LeftLittleDistal, 38, PlayerApiref);
            bonesset(HumanBodyBones.RightThumbProximal, 39, PlayerApiref);
            bonesset(HumanBodyBones.RightThumbIntermediate, 40, PlayerApiref);
            bonesset(HumanBodyBones.RightThumbDistal, 41, PlayerApiref);
            bonesset(HumanBodyBones.RightIndexProximal, 42, PlayerApiref);
            bonesset(HumanBodyBones.RightIndexIntermediate, 43, PlayerApiref);
            bonesset(HumanBodyBones.RightIndexDistal, 44, PlayerApiref);
            bonesset(HumanBodyBones.RightMiddleProximal, 45, PlayerApiref);
            bonesset(HumanBodyBones.RightMiddleIntermediate, 46, PlayerApiref);
            bonesset(HumanBodyBones.RightMiddleDistal, 47, PlayerApiref);
            bonesset(HumanBodyBones.RightRingProximal, 48, PlayerApiref);
            bonesset(HumanBodyBones.RightRingIntermediate, 49, PlayerApiref);
            bonesset(HumanBodyBones.RightRingDistal, 50, PlayerApiref);
            bonesset(HumanBodyBones.RightLittleProximal, 51, PlayerApiref);
            bonesset(HumanBodyBones.RightLittleIntermediate, 52, PlayerApiref);
            bonesset(HumanBodyBones.RightLittleDistal, 53, PlayerApiref);
            bonesset(HumanBodyBones.UpperChest, 54, PlayerApiref);
        }

        if (localwait && track)
        {
            localwait = false;
        }
        else if (localwait && Networking.IsOwner(gameObject))
        {
            track = true;
        }
    }
Exemplo n.º 27
0
 void Update()
 {
     if (TextOutput != null)
     {
         // if(localPlayer!=null){
         // pos = localPlayer.GetPosition();
         if (localPlayer != null)
         {
             pos = localPlayer.GetPosition();
         }
         string text = "X:" + pos.x + "\nY:" + pos.y + "\nZ:" + pos.z + "\n--AIOBJECTS--\n";
         if (AIObjects.Length > 0)
         {
             string txtAIs = "";
             foreach (AIObject g in AIObjects)
             {
                 txtAIs = txtAIs + "\n" +
                          g.gameObject.name + "\n" +
                          "Disabled:" + (g.disabled) + "\n" +
                          "mainturrets:" + (g.enableMainTurrets) + "\n" +
                          "dead:" + (g.dead) + "\n" +
                          "health:" + (g.Health) + "\n" +
                          "TargetString" + (g.TargetString) + "\n" +
                          "damagable:" + (g.damageable) + "\n";
                 if (localPlayer != null)
                 {
                     txtAIs = txtAIs + "Owner:" + ((Networking.GetOwner(g.gameObject)).displayName);
                 }
                 else
                 {
                     txtAIs = txtAIs + "Owner:" + "local";
                 }
                 string targets = "";
                 for (int x = 0; x < g.debugTargets.Length; x++)
                 {
                     targets = targets + g.debugTargets[x].name + "-" + g.targetIndices[x] + "\n";
                 }
                 txtAIs = txtAIs + "\nTargets:\n" + targets;
             }
             text = text + txtAIs;
         }
         if (AITurrets.Length > 0)
         {
             string txtTurrets = "";
             foreach (AITurretScript g in AITurrets)
             {
                 txtTurrets = txtTurrets + "\n" +
                              g.gameObject.name + "\n" +
                              "turretType:" + (g.turretType) + "\n";
                 if (g.Target != null)
                 {
                     txtTurrets = txtTurrets + "target:" + g.Target;
                 }
                 else
                 {
                     txtTurrets = txtTurrets + "target:null";
                 }
                 if (localPlayer != null)
                 {
                     txtTurrets = txtTurrets + "Owner:" + ((Networking.GetOwner(g.gameObject)).displayName);
                 }
                 else
                 {
                     txtTurrets = txtTurrets + "Owner:" + "local";
                 }
                 // "target:" +(g.Target!=null ? g.Target :null) + "\n" +
                 txtTurrets = txtTurrets + "\ntargetIndex::" + (g.currentTargetIndex) + "\n" +
                              "health:" + (g.Health) + "\n" +
                              "cooldown:" + (g.fireCooldown) + "\n" +
                              "launcharea:" + (g.launchArea) + "\n" +
                              "samlaunchareas:" + (g.MissileSpawnAreas.Length) + "\n" +
                              "isfiringciws:" + (g.isFiringCiws) + "\n" +
                              "isfiringprojectile:" + (g.isFiring) + "\n" +
                              "damagable:" + (g.damageable) + "\n";
             }
             text = text + txtTurrets;
         }
         TextOutput.text = text;
         // }
     }
 }
Exemplo n.º 28
0
 private void Update()
 {
     transform.SetPositionAndRotation(playerLocal.GetPosition(), playerLocal.GetRotation());
 }
Exemplo n.º 29
0
 public void Update()
 {
     Root.position = Player.GetPosition();
 }
Exemplo n.º 30
0
    void Update()
    {
        if (NowGaming)
        {
            if (GamePlayer.HP <= 0)
            {
                GamePlayer.FullHP();
                Death();
            }
        }
        if (GameStartTime > 0)
        {
            --GameStartTime;
        }
        else if (GameStartTime == 0)
        {
            GameStartTime = -1;
            SendCustomNetworkEvent(NetworkEventTarget.All, "JoinGame");
        }

        if (SetPosStartIndexStatus > 30)
        {
            if (Networking.GetOwner(this.gameObject).playerId == Networking.LocalPlayer.playerId)
            {
                PosStartIndex          = SetPosStartIndexValue;
                SetPosStartIndexStatus = -1;
            }
            else
            {
                SetPosStartIndexStatus = 10;
                Networking.SetOwner(Networking.LocalPlayer, this.gameObject);
            }
        }
        else if (SetPosStartIndexStatus >= 0)
        {
            ++SetPosStartIndexStatus;
        }

        if (SetLastStandingStatus > 30)
        {
            if (Networking.GetOwner(this.gameObject).playerId == Networking.LocalPlayer.playerId)
            {
                LastStandingID = SetLastStandingValue;
                Debug.Log("UDGLOG - SENDLASTSTANDID:" + LastStandingID.ToString());
                SetLastStandingStatus = -1;
                SendCustomNetworkEvent(NetworkEventTarget.All, "EndGame");
            }
            else
            {
                SetLastStandingStatus = 10;
                Networking.SetOwner(Networking.LocalPlayer, this.gameObject);
            }
        }
        else if (SetLastStandingStatus >= 0)
        {
            ++SetLastStandingStatus;
        }
        if (UpdateWinnerTimer >= 0)
        {
            if (UpdateWinnerTimer == 0)
            {
                var player = VRCPlayerApi.GetPlayerById(LastStandingID);
                if (player != null)
                {
                    WinnerText.text = "WINNER\n\n" + player.displayName;
                }
                UpdateWinnerTimer = -1;
            }
            else
            {
                --UpdateWinnerTimer;
            }
        }
        if (UpdateLivingStatusTimer >= 0)
        {
            if (UpdateLivingStatusTimer == 0)
            {
                var          distX      = 0f;
                var          distZ      = 0f;
                VRCPlayerApi livingLast = null;
                VRCPlayerApi player     = null;
                Vector3      playerPos  = new Vector3();
                Vector3      fieldPos   = GameField.GetComponent <Transform>().position;
                Vector3      fieldSize  = GameField.GetComponent <Transform>().localScale / 2f;
                Debug.Log("UDGLOG-FIELDPOS:" + fieldPos.ToString());
                Debug.Log("UDGLOG-FIELDSIZE:" + fieldSize.ToString());
                var id = -1;
                for (int i = 0; i < Player_IDs.Length; ++i)
                {
                    id = Player_IDs[i];
                    if (id != -1)
                    {
                        player    = VRCPlayerApi.GetPlayerById(id);
                        playerPos = player.GetPosition();
                        distX     = Mathf.Abs(playerPos.x - fieldPos.x);
                        distZ     = Mathf.Abs(playerPos.z - fieldPos.z);
                        Debug.Log("UDGLOG-PLAYERPOS:" + playerPos.ToString());
                        Debug.Log("UDGLOG-DISTX:" + distX.ToString());
                        Debug.Log("UDGLOG-DISTZ:" + distZ.ToString());
                        if (distX <= fieldSize.x && distZ <= fieldSize.z)
                        {
                            Debug.Log("UDGLOG - LIVING:" + player.displayName);
                            if (livingLast != null)
                            {
                                return;
                            }
                            livingLast = player;
                        }
                    }
                }
                if (livingLast != null)
                {
                    Debug.Log("UDGLOG - TRYSENDID:" + livingLast.playerId.ToString());
                    SetLastStandingValue  = livingLast.playerId;
                    SetLastStandingStatus = 0;
                }
                UpdateLivingStatusTimer = -1;
            }
            else
            {
                --UpdateLivingStatusTimer;
            }
        }
    }