- Home /
Unity Network problems, updating an individual object
I have this walk function that simply prints if a player is moving.
How can I use it to update the objects isMoving variable? It seems everything I try complains that it is a null object or the object is wrong. I have tried getting the game object and a few methods that might be too much to list. Any idea?
@RPC
function walk() {
print("a playe ris walking " + networkView.isMine);
//print(networkView.owner.AnimatePlayer.isMoving);
print(networkView.viewID);
print(gameObject.AnimatePlayers.isMoving);
}
so in AnimatePlayer.js
#pragma strict
static var isMoving: boolean = false;
function Start() {}
function Update() {
if (isMoving){
animation.Play("Walk");
}
else {
animation.Play("Idle");
}
}
The issue is that I need to set that specific objects animation to walking if they are walking.
[this is how I initialize player objects]
function spawnPlayer() {
var viewID = Network.AllocateViewID();
var clone : Transform;
clone = Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0) as Transform;
var nView: NetworkView;
nView = clone.GetComponent(NetworkView);
nView.viewID = viewID;
print(viewID);
}
Your answer
Follow this Question
Related Questions
Instantiated Object not appearing for remote players 0 Answers
Unity networking tutorial? 6 Answers
UNet changing player prefabs int the network lobby sample. 0 Answers
Can i make multiplayer game without unity multiplayer service ? 1 Answer
【PUN2】I want to disable the instantiation of an object in PhotonView at a specified time. 1 Answer