xulipa
NNormal
•Created by fgamez1020 on 10/10/2024 in #🤝ask-a-question
How to wait for four players are connected and then start the game?
using System;
using Normal.Realtime;
using UnityEngine;
public class UpdateAvatar : MonoBehaviour
{
public static int intClientID;
public static event Action<bool> LocalPlayerConnected;
public static RealtimeAvatarManager _realtimeAvatarManager;
public static RealtimeAvatar _realtimeAvatar;
public static Realtime _realtime;
private void Awake()
{
_realtimeAvatarManager = GetComponent<RealtimeAvatarManager>();
_realtimeAvatarManager.avatarCreated += AvatarCreated;
}
private void OnEnable()
{
if (_realtime != null)
_realtime.didDisconnectFromRoom += DidDisconnectFromRoom;
_realtimeAvatarManager.avatarCreated += AvatarCreated;
}
private void OnDisable()
{
if (_realtime != null)
_realtime.didDisconnectFromRoom -= DidDisconnectFromRoom;
}
private void AvatarCreated(RealtimeAvatarManager avatarManager, RealtimeAvatar avatar, bool isLocalAvatar)
{
if (isLocalAvatar)
{
_realtimeAvatar = avatar;
LocalPlayerConnected?.Invoke(true);
Realtime realtime = avatar.realtime;
uint clientID = (uint)realtime.clientID;
intClientID = (int)clientID;
// Debug.Log("Your client ID:" + intClientID);
}
}
13 replies
NNormal
•Created by fgamez1020 on 10/10/2024 in #🤝ask-a-question
How to wait for four players are connected and then start the game?
This is how I'm using it. I got an UpdateAvatar script that has the realtime stuff in it.
13 replies
NNormal
•Created by fgamez1020 on 10/10/2024 in #🤝ask-a-question
How to wait for four players are connected and then start the game?
if (UpdateAvatar._realtimeAvatarManager.avatars.Count > 3)
13 replies
NNormal
•Created by Marlon Stein on 10/14/2024 in #🤝ask-a-question
isOwnedLocallySelf during Start()
Ahh okay nvm then
10 replies
NNormal
•Created by Marlon Stein on 10/14/2024 in #🤝ask-a-question
isOwnedLocallySelf during Start()
I normally check if the client is connected to the room before doing anything Normcore related - which usually takes a couple of seconds atleast.
10 replies
NNormal
•Created by fgamez1020 on 10/10/2024 in #🤝ask-a-question
How to wait for four players are connected and then start the game?
You can check how many players are in the room using clientID
13 replies
NNormal
•Created by xulipa on 8/23/2024 in #🤝ask-a-question
Prevent ownership toggle
Thanks I previously thought sometime like this would be a bit too hacky, but since as you mentioned RT doesn't support parenting, this must be the best solution
13 replies
NNormal
•Created by xulipa on 8/23/2024 in #🤝ask-a-question
Prevent ownership toggle
Should I check ownership of Realtime.Transform only or also of Realtime.View?
Ohh yeah that's what I thought.
13 replies
NNormal
•Created by xulipa on 8/23/2024 in #🤝ask-a-question
Prevent ownership toggle
I have a prefab I instantiate after connection. However it's behaving a bit strange since when I'm using the weapon it has a vibrate script but my controller also vibrates when the other players are using it (this might be solvable with checking isOwnedLocallySelf in script?). Also I tried with having the weapon childed in the XR rig on the hand, but then it would show up with a big offset etc. So not sure what's the best way to spawn in objects in the hand of the player.
13 replies
NNormal
•Created by xulipa on 8/23/2024 in #🤝ask-a-question
Prevent ownership toggle
Ahh makes sense.
13 replies
NNormal
•Created by xulipa on 8/14/2024 in #🤝ask-a-question
Changing scene room duplicates XR Origin
@Normcore Assistant can you change the script into Additive Scene/Room loading instead
15 replies
NNormal
•Created by xulipa on 8/14/2024 in #🤝ask-a-question
Changing scene room duplicates XR Origin
Because in this video I see that they are removing their XR Origin from the scene. Which I cannot because I'm using a different XR Origin for every scene: https://www.youtube.com/watch?v=AGMKZcL_CuI
15 replies
NNormal
•Created by xulipa on 8/14/2024 in #🤝ask-a-question
Changing scene room duplicates XR Origin
So that's some native Unity system code I would be looking for?
15 replies
NNormal
•Created by xulipa on 8/4/2024 in #🤝ask-a-question
Animate hands on avatar
Appreciated. Will try this in a couple of days!
9 replies