public override void OnPlayerParticleCollision(VRCPlayerApi player) { if (player == Networking.LocalPlayer) { if ((layers.value & 1 << LayerMask.NameToLayer("PlayerLocal")) == 0) { return; } } else { if ((layers.value & 1 << LayerMask.NameToLayer("Player")) == 0) { return; } } Trigger(); }
public static void SetOwner(this GameObject obj, VRCPlayerApi player) { if (Networking.GetOwner(obj) == player) { return; } ICyanEmuSyncable[] syncs = obj.GetComponents <ICyanEmuSyncable>(); foreach (ICyanEmuSyncable sync in syncs) { sync.SetOwner(player.playerId); } ICyanEmuSyncableHandler[] syncHandlers = obj.GetComponents <ICyanEmuSyncableHandler>(); foreach (ICyanEmuSyncableHandler syncHandler in syncHandlers) { syncHandler.OnOwnershipTransferred(player.playerId); } }
void OnPlayerJoined(VRCPlayerApi player) { // Ignore this if we are the one joining if (player == Networking.LocalPlayer) { return; } if (Networking.GetOwner(main.gameObject) == Networking.LocalPlayer) { FRP(FRP_LOW + "Player joined, updating him on state" + FRP_END); // Send all the other states they need to catch up on _b7_send((byte)(k_7b_menu_loc | menu_loc)); _b7_send((byte)(k_7b_ball_col | colour_id)); _b7_send((byte)(k_7b_timelimit | timer_id)); _b7_send((byte)(k_7b_gamemode | gamemode_id)); } }
public void OnInteraction() { Debug.Log("[Thry] Try Teleport \"" + name + "\""); if (Networking.LocalPlayer != null) { if (isPlayerTeleport) { VRCPlayerApi target = null; VRCPlayerApi[] players = new VRCPlayerApi[VRCPlayerApi.GetPlayerCount()]; VRCPlayerApi.GetPlayers(players); foreach (VRCPlayerApi p in players) { if (p.displayName == name) { target = p; } } if (target != null) { Debug.Log("[Thry] Execute Teleport to \"" + target.displayName + "\" at " + target.GetPosition()); Ray ray = new Ray(target.GetPosition() + target.GetRotation() * Vector3.back + Vector3.up * 2, Vector3.down); RaycastHit hit; if (Physics.Raycast(ray, out hit, 5)) { ExecuteTeleport(hit.point, target.GetRotation()); } else { Debug.Log("[Thry] Could not find floor to teleport to."); } } } else if (target != null) { ExecuteTeleport(target.position, target.rotation); } else { Debug.Log("[Thry] Teleport Point not specified."); } } }
// Update is called once per frame void Update() { if (localUser != null || RunWithoutPlayer) { if (Input.GetKeyDown(DesktopJumpOffSnowboardKey)) { localUser = null; } SnowboardingUpdate(); } if (transform.position.y < -100) { ResetSnowboard(); } else if (lastUsageTime != -1 && Time.time - lastUsageTime > ResetTimeoutAfterUsage) { ResetSnowboard(); } }
private void Start() { //Find Height Tracker GameObject o = GameObject.Find("[Thry]AvatarHeightTracker"); if (o == null) { Debug.LogError("Can't Find AvatarHeightTracker"); return; } _avatarHeightTracker = o.GetComponent <AvatarHeightTracker>(); _audioSource = this.GetComponent <AudioSource>(); _player = Networking.LocalPlayer; if (_player == null) { return; } _isNotVR = !Networking.LocalPlayer.IsUserInVR(); }
private void RemovePlayer(VRCPlayerApi player) { var id = player.playerId; VRCPlayerApi prevPlayer = null; for (int i = Players.Length - 1; i >= 0; i--) { var currentPlayer = Players[i]; Players[i] = prevPlayer; if (currentPlayer == null) { continue; } if (currentPlayer.playerId == id) { return; } prevPlayer = currentPlayer; } }
private void Update() { VRCPlayerApi PlayerApiref = Networking.GetOwner(gameObject); if (PlayerApiref != null && track) { gettracking(head, VRCPlayerApi.TrackingDataType.Head, PlayerApiref); gettracking(lefthand, VRCPlayerApi.TrackingDataType.LeftHand, PlayerApiref); gettracking(righthand, VRCPlayerApi.TrackingDataType.RightHand, PlayerApiref); } if (localwait && track) { localwait = false; } else if (localwait && Networking.IsOwner(gameObject)) { track = true; } }
public override void OnPlayerJoined(VRCPlayerApi player) { if (!player.isLocal) { // Player voice player.SetVoiceGain(voiceGain); player.SetVoiceDistanceFar(voiceFar); player.SetVoiceDistanceNear(voiceNear); player.SetVoiceVolumetricRadius(voiceVolumetricRadius); player.SetVoiceLowpass(!voiceDisableLowpass); // Avatar audio player.SetAvatarAudioGain(avatarMaxAudioGain); player.SetAvatarAudioFarRadius(avatarMaxFarRadius); player.SetAvatarAudioNearRadius(avatarMaxNearRadius); player.SetAvatarAudioVolumetricRadius(avatarMaxVolumetricRadius); player.SetAvatarAudioForceSpatial(avatarForceSpacialization); player.SetAvatarAudioCustomCurve(!avatarDisableCustomCurve); } }
public void Update() { Guardian.text = manager.Guardian == null ? "Guardian: NULL" : $"Guardian: {manager.Guardian.displayName}({manager.Guardian.playerId})"; Ward.text = manager.Ward == null ? "Ward: NULL" : $"Ward: {manager.Ward.displayName}({manager.Ward.playerId})"; IsHead.text = $"IsHead: {manager.isHead}"; IsTail.text = $"IsTail: {manager.isTail}"; MasterHandler.text = manager.masterHandler == null ? "Master Handler: NULL" : $"Master Handler: {manager.masterHandler.name}"; string assignedHandler = manager.assignedHandler == null ? "NULL" : $"{manager.assignedHandler.name}"; Handler.text = $"Handler: {manager.handlerAssigned}, {assignedHandler}"; VRCPlayerApi messengerOwner = Networking.GetOwner(manager.messenger.gameObject); MessengerOwner.text = $"Messenger Owner: {messengerOwner.displayName}({messengerOwner.playerId})"; Message.text = $"Message: {manager.messenger.MESSAGE}"; LastMessage.text = $"{manager.messenger.last_MESSAGE}"; }
public override void OnStationEntered(VRCPlayerApi player) { Debug.Log(player.displayName + player.displayName.Length + " entered station"); followerToAssign.followedPlayerApi = player; if (player.isLocal) { Networking.SetOwner(player, followerToAssign.gameObject); Networking.SetOwner(player, station.gameObject); isSitting = true; //station.gameObject.SetActive(false); //station.ExitStation(Networking.LocalPlayer); } else { //station.gameObject.SetActive(false); //station.PlayerMobility = VRCStation.Mobility.Immobilize; } }
private bool CheckAccess(VRCPlayerApi toCheck) { if (!restrictAccess) { return(true); } var hasAccess = false; var pName = toCheck.displayName; foreach (var u in allowedUsers) { if (String.Equals(u, pName, StringComparison.InvariantCultureIgnoreCase)) { hasAccess = true; break; } } return(hasAccess); }
public override void OnPlayerRespawn(VRCPlayerApi player) { if (!exitZoneOnRespawn) { return; } if (!Contains(player)) { return; } if (!udonDebug.Assert(Utilities.IsValid(player), "player invalid", this) || !player.isLocal) { return; } ExitRoom(player, optionalRespawnLocation); }
private static bool OnPlayerLeave(ref VRCPlayerApi __0) { try { if (__0 != null) { if (PlayerCache.Contains(__0.displayName)) { for (var i = 0; i < GeneralUtils.Modules.Count; i++) { GeneralUtils.Modules[i].OnPlayerLeft(__0); } PlayerCache.Remove(__0.displayName); } } } catch { } return(true); }
private VRCPlayerApi FindWard() { VRCPlayerApi ward = null; for (int i = lastLateJoinerSlot; i >= 0; i--) { VRCPlayerApi potentialWard = lateJoiners[i]; if (potentialWard == null || potentialWard == lastLeaver) { lastLateJoinerSlot--; continue; } if (ward == null || potentialWard.playerId < ward.playerId) { ward = potentialWard; } } return(ward); }
public bool EnterRoom(VRCPlayerApi localPlayer, Transform optionTeleportLocation) { if (!udonDebug.Assert(Utilities.IsValid(localPlayer), "Invalid local player", this)) { return(false); } if (!udonDebug.Assert(localPlayer.isLocal, "Player is not local", this)) { return(false); } if (!udonDebug.Assert(AddLocalPlayerToZone(localPlayer), "Failed adding player to zone", this)) { return(false); } TeleportPlayer(optionTeleportLocation); return(true); }
/// <summary> /// Initializing the scene /// </summary> public void CustomStart(float buttonVolume) { Debug.Log("[ElevatorController] is now in Start()"); _localPlayer = Networking.LocalPlayer; //getting material renderer _topStatePanelRenderer1 = _topStatePanel1.GetComponent <Renderer>(); _topStatePanelRenderer2 = _topStatePanel2.GetComponent <Renderer>(); _topStatePanelRenderer3 = _topStatePanel3.GetComponent <Renderer>(); _elevator1numberDisplayRenderer_LOD0 = _elevator1numberDisplay_LOD0.GetComponent <Renderer>(); _elevator1numberDisplayRenderer_LOD1 = _elevator1numberDisplay_LOD1.GetComponent <Renderer>(); _elevator1numberDisplayRenderer_LOD2 = _elevator1numberDisplay_LOD2.GetComponent <Renderer>(); _elevator2numberDisplayRenderer_LOD0 = _elevator2numberDisplay_LOD0.GetComponent <Renderer>(); _elevator2numberDisplayRenderer_LOD1 = _elevator2numberDisplay_LOD1.GetComponent <Renderer>(); _elevator2numberDisplayRenderer_LOD2 = _elevator2numberDisplay_LOD2.GetComponent <Renderer>(); _elevator3numberDisplayRenderer_LOD0 = _elevator3numberDisplay_LOD0.GetComponent <Renderer>(); _elevator3numberDisplayRenderer_LOD1 = _elevator3numberDisplay_LOD1.GetComponent <Renderer>(); _elevator3numberDisplayRenderer_LOD2 = _elevator3numberDisplay_LOD2.GetComponent <Renderer>(); //setting elevators into closed state _topStatePanelRenderer1.materials[0].DisableKeyword("_EMISSION"); _topStatePanelRenderer2.materials[0].DisableKeyword("_EMISSION"); _topStatePanelRenderer3.materials[0].DisableKeyword("_EMISSION"); _elevator1DoorCollider.enabled = true; _elevator2DoorCollider.enabled = true; _elevator3DoorCollider.enabled = true; _elevator1.SetActive(false); _elevator2.SetActive(false); _elevator3.SetActive(false); CloseElevator(0, false); CloseElevator(1, false); CloseElevator(2, false); //Setting up lower scripts _elevatorCallPanelDesktop_1.CustomStart(buttonVolume); _elevatorCallPanelDesktop_2.CustomStart(buttonVolume); _elevatorCallPanelForVR_1.CustomStart(buttonVolume); _elevatorCallPanelForVR_2.CustomStart(buttonVolume); if (_avatarHeight != 1.1f) { OnAvatarChanged(); } _scriptIsLoaded = true; }
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(); }
// 視線追従 private void OnAnimatorIK(int layerIndex) { if (!targetik) { return; } Vector3 lookpos = Vector3.zero; float ikbody_new = ikbody; float ikhead_new = ikhead; if (selected > 0 && state >= 2 && state <= 3) // 拾いに行くまで { // ボールを見る if (_tgroot.transform.GetChild(selected - 1) != null && agent.remainingDistance < 3.0f) //目標がセットされ距離が3m以内 { lookpos = _tgroot.transform.GetChild(selected - 1).transform.position; } } if (selected > 0 && state >= 6 && state <= 8) // 渡すとき、なでなで、終了 { // ボールを投げた人(Owner)の頭を見る GameObject ball = _tgroot.transform.GetChild(selected - 1).gameObject; VRCPlayerApi owner = Networking.GetOwner(ball); if (owner != null) { lookpos = owner.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).position; // オーナーの頭位置 } ikbody_new = 0.1f; // 体は曲げない if (state == 8) // 終了時(なでなで有効時間内) { ikbody_new = 0f; ikhead_new = 0f; } } if (lookpos != Vector3.zero) { //animator.SetLookAtWeight(ikall, ikbody_new, ikhead, ikeye, ikmotion); // 全体,体,頭,目,モーション animator.SetLookAtWeight(Soft(ikall, 0), Soft(ikbody_new, 1), Soft(ikhead_new, 2), Soft(ikeye, 3), Soft(ikmotion, 4)); animator.SetLookAtPosition(lookpos); } }
public override void OnStationExited(VRCPlayerApi player) { if (firsttime) { InitializeSeat(); } AAGunControl.LastHealthUpdate = Time.time; if (player.isLocal) { AAGunControl.Manning = false; AAGunControl.firing = false; AAGunControl.AAMLockTimer = 0; AAGunControl.AAMHasTarget = false; AAGunControl.DoAAMTargeting = false; AAGunAnimator.SetBool("inside", false); if (SeatAdjuster != null) { SeatAdjuster.SetActive(false); } } }
private void Start() { // Match lerped positions at start lag_objBase = this.transform.position; lag_objTarget = objTarget.transform.position; #if !HT_QUEST dkShotDist = k_dkShotReset; #endif targetOriginalDelta = this.transform.InverseTransformPoint(objTarget.transform.position); OnDrop(); pickup_this = (VRC_Pickup)this.gameObject.GetComponent(typeof(VRC_Pickup)); pickup_target = (VRC_Pickup)objTarget.GetComponent(typeof(VRC_Pickup)); reset_pos_target = objTarget.transform.position; reset_pos_this = this.transform.position; localplayer = Networking.LocalPlayer; }
/* * public void CheckEndRoundPlayerLeft() * { * if (AreThereEnoughVotesToEndTheRound()) isRoundOver = true; * RequestSerialization(); * OnDeserialization(); * }*/ public override void OnPlayerLeft(VRCPlayerApi player) { if (!Networking.LocalPlayer.isMaster) { return; } foreach (var p in playerManagers) { p.PlayerHasLeft(player); } for (var index = 0; index < playerManagers.Length; index++) { var p = playerManagers[index]; TryBonusPointPlacement(index); // Later joiners could change the situation... p.RequestSerialization(); p.OnDeserialization(); } UpdateIsRoundOver(); }
public VRCPlayerApi[] GetOccupants() { VRCPlayerApi[] allPlayers = new VRCPlayerApi[VRCPlayerApi.GetPlayerCount()]; VRCPlayerApi.GetPlayers(allPlayers); VRCPlayerApi[] occupants = new VRCPlayerApi[occupancy]; int n = 0; foreach (var player in allPlayers) { // XXX apparently GetPlayers can sometimes have null in it. if (player == null) { continue; } if (lookup(player.playerId, playerIdKeys, playerInSet)) { occupants[n++] = player; } } return(occupants); }
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); }
private void OnPlayerLeft(VRCPlayerApi player) { int masterID = CyanEmuPlayerManager.GetMasterID(); VRCPlayerApi masterPlayer = VRCPlayerApi.GetPlayerById(masterID); foreach (CyanEmuSyncedObjectHelper sync in allSyncedObjects_) { if (sync == null) { continue; } GameObject syncObj = sync.gameObject; if (Networking.GetOwner(syncObj)?.playerId == player.playerId) { Networking.SetOwner(masterPlayer, syncObj); } } sdkManager_.OnPlayerLeft(player); }
private bool TestGettingPlayerInfo() { Debug.Log("TestGettingPlayerInfo"); Debug.Log("GetPlayerById(-1)"); VRCPlayerApi player = VRCPlayerApi.GetPlayerById(-1); if (player != null) { Debug.LogError("Player -1 is not null?"); return(false); } Debug.Log("GetPlayerById(1)"); player = VRCPlayerApi.GetPlayerById(1); if (player == null) { Debug.LogError("Player 1 is null"); return(false); } Debug.Log("GetPlayerId(_localPlayer)"); int id = VRCPlayerApi.GetPlayerId(_localPlayer); if (id != _localPlayer.playerId) { Debug.LogError("GetPlayerId returned the wrong value for the local player"); return(false); } Debug.Log("GetPlayerId(null)"); id = VRCPlayerApi.GetPlayerId(null); if (id != -1) { Debug.LogError("GetPlayerId returned the wrong value for the local player"); return(false); } return(true); }
private void AddPlayer(VRCPlayerApi player) { if (player.playerId > playerCount) { UpdateTotalPlayerCount(player.playerId); } GameObject newPlayerlistPanel = VRCInstantiate(PlayerListItem); if (player.displayName == CreatorName) { newPlayerlistPanel.GetComponent <Image>().color = CreatorColor; } Transform t = newPlayerlistPanel.transform; t.SetParent(PlayerList.transform); t.localPosition = new Vector3(); t.localEulerAngles = new Vector3(); t.localScale = new Vector3(1, 1, 1); t.GetChild(1).GetComponent <Text>().text = player.playerId.ToString(); t.GetChild(2).GetComponent <Text>().text = player.displayName; t.GetChild(3).GetComponent <Text>().text = (player.playerId < localPlayer.playerId) ? "Joined before you" : DateTime.UtcNow.ToLocalTime().ToString("dd MMMM yyyy hh:mm:ss"); if (player.IsUserInVR()) { t.GetChild(4).gameObject.SetActive(true); } if (IsNameInGroup(player.displayName, Group1Names)) { t.GetChild(5).gameObject.SetActive(true); } if (IsNameInGroup(player.displayName, Group2Names)) { t.GetChild(6).gameObject.SetActive(true); } }
void Start() { _playerLocal = Networking.LocalPlayer; bool isUserInVR = _playerLocal.IsUserInVR(); if (isUserInVR) { // VR mode if (isVRComponent) { Debug.Log("VR mode VR component on"); // set the VR keypad on VRComponent.SetActive(true); } else { Debug.Log("VR mode desktop component off"); // set the Desktop keypad off DesktopComponent.SetActive(false); } } else { // Desktop mode if (isVRComponent) { Debug.Log("Desktop mode VR component off"); // set the VR keypad off VRComponent.SetActive(false); } else { Debug.Log("Desktop mode desktop component on"); // set the Desktop keypad on DesktopComponent.SetActive(true); } } }
public override void OnPlayerTriggerExit(VRCPlayerApi player) { if (!active) { return; } if (!collideWithLocalPlayers && !collideWithRemotePlayers && !shouldCollideWithPlayers) { return; } if (player == null) { return; } if (!Utilities.IsValid(player)) { return; } var isLocal = player.isLocal; if (isLocal && (collideWithLocalPlayers || shouldCollideWithLocals)) { if (collidersIn == 1) { FireTriggers("exit"); collidersIn--; return; } } if (!isLocal && (collideWithRemotePlayers || shouldCollideWithRemote)) { if (collidersIn == 1) { FireTriggers("exit"); collidersIn--; return; } } }
public void OnRoundChanged(int seed, int round) { playerUI.MakeAllPromptsNeutral(); localHasVoted = gameManager.GetMyPlayerManagerId() < 0 ? true : false; // players who don't have an id should not vote if (round < 0) { UpdateInstructions(); return; } if (Networking.IsMaster) { AskOwnerClearLines(); } if (!Utilities.IsValid(VRCPlayerApi.GetPlayerById(ownerPlayerId))) { ownerPlayerId = -1; } if (ownerPlayerId < 0) { isPlaying = false; playerUI.SetPromptsVisible(false); UpdateInstructions(); return; } playerUI.SetPromptsVisible(true); isPlaying = true; ResetVotes(); correctIndex = GetCorrectIndex(seed, round); if (LocalIsOwner()) { playerUI.SetPromptCorrect(correctIndex); } UpdateInstructions(); }