- Home /
Question by
lilsheep · Mar 09, 2014 at 09:46 AM ·
networkingnetworkviewonserializenetworkview
Proper if condition for network view
What the scrip is doing is it is setting and saving isMoving on the server.
How do I check in the if statement that the user is the right user? Because when one user moves isMoving seems to become true for all users--when I remove the && networkView.isMine then it becomes true for all users when any one user moves.
How do I check that it is true for a specific user? Any idea of how to get this right. [ I want one user to animate for all users watching it][what is happening is it is only animating for itself]
function Update() {
if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D)) {
isMoving = true;
}
if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.D)){
isMoving = false;
}
var child = transform.Find("knight");
if (isMoving && networkView.isMine ){
child.animation.Play("Walk");
}
else {
child.animation.Play("Idle");
}
}
function OnSerializeNetworkView(stream : BitStream, info : NetworkMessageInfo) {
var _isMoving : boolean = isMoving;
stream.Serialize(_isMoving);
}
Comment