Using this quick tutorial… How to create an online multiplayer game with Unity - Paladin Studios Ive been trying to build my own multilayer game however I cannot fix the problem of controlling all the players who are connected to the server. Ive read many questions like this but I haven’t found my answer. The tutorial I’ve been following shows how to prevent this from happened using networkview.ismine but only for a cube with a simple WASD movement script. I’m trying to do this using the FPS controller. This is my best attempt at solving this problem but it does not work, any help on this?
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
private CharacterMotor characterMotor;
void Awake(){
characterMotor = GetComponent<CharacterMotor> ();
}
void Update(){
if (networkView.isMine){
characterMotor.enabled = false;
}
else{
characterMotor.enabled = true;
}
}
}
This makes other players control the players around them not themselves, does something need to be flipped?
These two lines of code should do the trick, for better performance place them in the start function since you aren't changing the owner of the objects. If you tend to use the script after remove the second line.
Here is what your update function should look like:
void Update(){
if (networkView.isMine){
characterMotor.enabled = true;//this was originally false
}
else{
characterMotor.enabled = false;//this was originally true
}
}
}
Just like Makak was saying when this is your character you can’t move it but everyone else moves everyone else’s character.
This makes other players control the players around them not themselves, does something need to be flipped?
– Blink