- Home /
MUltiplayer
I have made a multiplayer game that makes a first person controller spawn when they press start server. Now i went on another computer to do the same and it spawned in the same spot and one person moves both of them. HELP please.
are you using Unity's Networkng? or SmartFox or something else?
Answer by williampigmeu · Sep 04, 2012 at 02:42 AM
function Start(){ if(!NetworkView.ismine){ MovementControlScript.enabled = false; } }
This will work fine.
Answer by strachpr01 · Aug 05, 2012 at 12:21 PM
Add a network view to your objects then use
Void Start(){
If(!NetworkView.is mine){
Playercontrolscript.enabled=false;
}
}
that is C#, a javascript conversion would look like this:
function Start() { If(!NetworkView.is $$anonymous$$e){
Playercontrolscript.enabled=false;
}
}
There is a error that says, BCE0044: expecting ), found '$$anonymous$$e'.
and BCE0043: Unexpected token: ).
and lastly BCE0044: expecting :, found '='.
What did I do wrong?
There are mistakes in these examples, guys. C# should read 'void' and not 'Void', also 'is $$anonymous$$e' is not even a valid variable name, you meant 'is$$anonymous$$ine'.
Parsing error Unexpected symbol `{'
A namespace can only contain types and namespace declarations.?
what am I doing worng????
Answer by draulleo · Sep 02, 2012 at 07:15 PM
Nonono, Just go to Player Setting and do Run in Background at one of the options :D
function Start(){ if(!NetworkView.is$$anonymous$$e){ $$anonymous$$ovementControlScript.enabled = false; } }
Works fine for me.
I got this error,BCE0005: $$anonymous$$ identifier: '$$anonymous$$ovementControlScript'.
$$anonymous$$ovementcontrolscript needs to be changed to the name of the script that is controlling your player
Answer by rokyed · Sep 29, 2012 at 07:21 AM
i suggest only to implement this :
in the controller script :
define a variable as boolean like :
var thisOneIsMine=false;
function Start(){
if(networkView.isMine){
thisOneIsMine=true;
}else{
thisOneIsMine=false;
}
}
function Update(){
//or FixedUpdate or whatever function u want
if(thisOneIsMine){
//do here all the controller implementation
//like : inputs , speeds directions rotations
}
}
this is how i did it and i am new to network
Answer by FaZeY Designs · Dec 16, 2012 at 01:53 PM
Im new to scripting but i edited on of your scripts and found this worked. If you are using the FPS Controller that came with the standard assets do the following:
create a C# script and name it IsMyPlayer.
Copy and past the script below.
Save and add to camera.
using UnityEngine; using System.Collections;
public class IsMyPlayer : MonoBehaviour {
void Start() {
if(! networkView.isMine) { GetComponent().enabled=false;
}
} }
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Multiplayer FPS Bullets: should they be rigid bodies or raycast? 1 Answer
What am I doing wrong? (Scripting question) 1 Answer
Need help with AI in multiplayer 1 Answer
StarTrooper Download 0 Answers