MasterOX 水
MasterOX 水4mo ago

multiplayer party game like kahoot

i want to know if a multiplayer party game like kahoot is doable, the idea is that the server is a screen and the clients are phones that act as controllers for the screen
2 Replies
kapa.ai
kapa.ai4mo ago
Hi @MasterOX 水. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, creating a multiplayer party game like Kahoot is doable using the NormalVR platform. You can create a multiplayer environment where the server acts as the main screen and the clients (players) use their phones as controllers. To achieve this, you would need to create a player controller that can be instantiated for every player in the multiplayer room. This can be done by adding a RealtimeView to the Player, creating a Resources folder, and dragging the Player into the Resources folder. You can then delete it from the scene once this is done. You would also need to create a script to instantiate a copy of the prefab after you connect to a room. This script would also wire up the Parent Constraint reference so the camera follows the newly instantiated player prefab. Here is a sample code for this:
using UnityEngine;
using UnityEngine.Animations;
using Normal.Realtime;

public class PlayerManager : MonoBehaviour {
[SerializeField] private GameObject _camera = default;

private Realtime _realtime;

private void Awake() {
// Get the Realtime component on this game object
_realtime = GetComponent<Realtime>();

// Notify us when Realtime successfully connects to the room
_realtime.didConnectToRoom += DidConnectToRoom;
}

private void DidConnectToRoom(Realtime realtime) {
// Instantiate the Player for this client once we've successfully connected to the room
GameObject playerGameObject = Realtime.Instantiate( prefabName: "Player", // Prefab name
ownedByClient: true, // Make sure the RealtimeView on this prefab is owned by this client
preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
useInstance: realtime); // Use the instance of Realtime that fired the didConnectToRoom event.

// Get a reference to the player
Player player = playerGameObject.GetComponent<Player>();

// Get the constraint used to position the camera behind the player
ParentConstraint cameraConstraint = _camera.GetComponent<ParentConstraint>();

// Add the camera target so the camera follows it
ConstraintSource constraintSource = new ConstraintSource { sourceTransform = player.cameraTarget, weight = 1.0f };
using UnityEngine;
using UnityEngine.Animations;
using Normal.Realtime;

public class PlayerManager : MonoBehaviour {
[SerializeField] private GameObject _camera = default;

private Realtime _realtime;

private void Awake() {
// Get the Realtime component on this game object
_realtime = GetComponent<Realtime>();

// Notify us when Realtime successfully connects to the room
_realtime.didConnectToRoom += DidConnectToRoom;
}

private void DidConnectToRoom(Realtime realtime) {
// Instantiate the Player for this client once we've successfully connected to the room
GameObject playerGameObject = Realtime.Instantiate( prefabName: "Player", // Prefab name
ownedByClient: true, // Make sure the RealtimeView on this prefab is owned by this client
preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
useInstance: realtime); // Use the instance of Realtime that fired the didConnectToRoom event.

// Get a reference to the player
Player player = playerGameObject.GetComponent<Player>();

// Get the constraint used to position the camera behind the player
ParentConstraint cameraConstraint = _camera.GetComponent<ParentConstraint>();

// Add the camera target so the camera follows it
ConstraintSource constraintSource = new ConstraintSource { sourceTransform = player.cameraTarget, weight = 1.0f };
(Source: Creating a Player Controller (https://normcore.io/documentation/guides/creating-a-player-controller#making-it-multiplayer)) For the game to work on phones, you can use Normcore's WebGL support which allows any Normcore project to be compiled for WebGL with no modifications to the source project. This means that the game can be played on a web browser on a phone. (Source: WebGL (https://normcore.io/documentation/platforms/webgl)) However, getting a list of all rooms and how many players are in them is something that you would need to manage yourself as it is not currently supported by Normcore. (Source: Common Questions (https://normcore.io/documentation/architecture/common-questions#how-do-i-get-a-list-of-all-rooms-and-how-many-players-are-in-them)) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@758040514678489279> kapa.ai is still learning and improving, please let us know how it did by reacting below