- Home /
On multiplayer games, how do you control only your character?
How do people go about placing multiple characters but you can only control your own? I don't understand that part.
I don't really understand your question but it's because you have only your character who has a controller script.
If you want to know how others players can control their character and not another it depends of your implementation.
In one of our game when we instantiate our level, our character got the controller script and others players characters are detected as NPC ( but are controllable by their player)
Answer by weenchehawk · Feb 02, 2013 at 01:11 AM
In your client, add your player controller script to your object after you do network.instantiate() Something like
using UnityEngine;
public class PlayerSpawnEngine : MonoBehaviour
{
public Object PlayerPrefab; // set this in the inspector / editor
private GameObject Player;
void OnConnectedToServer()
{
GameObject Player = Network.Instantiate( PlayerPrefab, OurPosition, OurOrientation, 0) as GameObject);
Player.AddComponent<PlayerController>();
}
void OnDisconnectedFromServer(NetworkDisconnection info)
{
Player = null;
}
}
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
How to make camera position relative to a specific target. 1 Answer
Most efficient way to structure a huge online "virtual world" 0 Answers
attached prefabs before client joins 2 Answers
Iphone, android multiplayer app 2 Answers