[ad_1]
I am creating an FPS game in local multiplayer. One player creates the hot-spot game, and the other one connects through WiFi network and plays the game. And i am doing this using unity MultiLan Package available in Unity Assets Store.
when the player connect to the Game i play the player animation like walk , jump etc. But the problem is animation can play only which player who host the Game, not play to other player who join the Game in host network.
That is Player Script.
private MNetwork networkSrc;
public Btn_Jump jumpScript;
public Btn_DPad Btn_DpadScript;
void Awake() {
if (GetComponent<NetworkView>().isMine) {
trans = transform;
contr = trans.GetComponent<CharacterController>();
if (jumpScript == null) {
jumpScript = GameObject.Find ("3 Jump").GetComponent<Btn_Jump> ();
}
if (Btn_DpadScript == null) {
Btn_DpadScript = GameObject.Find ("6 D-Pad").GetComponent<Btn_DPad> ();
}
}
}
void Start() {
if (GetComponent<NetworkView>().isMine) {
// If it's my player : search the networkManager component
networkSrc = GameObject.Find("MNetwork").GetComponent<MNetwork>();
PlayerAnimatorComponent = GameObject.Find ("Swat").GetComponent<Animator> ();
FPS_Events.ChangeCharacterMotor(motor);
}
}
void Update() {
if (!networkSrc.isPlayerExitGame) {
if (currentMotor == null)
FPS_Events.ChangeCharacterMotor (motor);
try {
currentMotor.Update ();
} catch {
}
if (jumpScript.Player_jump) {
}
if (Btn_DpadScript.Player_Run) {
RunAnimation ();
}
}
}
void RunAnimation(){
GetComponent<NetworkView> ().RPC ("SyncAnimation", RPCMode.All);
}
[RPC]
void SyncAnimation(){
if (Btn_DpadScript.Player_Run) {
PlayerAnimatorComponent.SetFloat ("Walk",2f,0.1f,Time.deltaTime);
}
}
In this Script there is “Btn_DpadScript” object of Virtual joystick Script name is “Btn_DPad” for Player Movement.
When player move then “Player_Run” Boolean variable is true and play the Walk animation of player in SyncAnimation() method.
But it is stuck to play animation in all player in same network.
Any one can know how to play animation in all network player using MultiLan Package then tell me. I can’t found in Google Search about player Animation in network using MultiLan Package.
what should i do don’t know any one can suggestion then i really appreciate thank you.
[ad_2]