- Home /
play animations (multiplayer)
my problem is that i want animations to play for example "walk""run" and so on but when I join my server it doesn't play any animations.....i already added a "network view" to the character to look at the position and rotation ....and added this script to update the position on the server ....but how can i make this work for animations???? please some one help im completely stuck, ive tried to read about PRC's but i just don't get it:(..
the update character position script:
using UnityEngine;
using System.Collections;
/// <summary>
/// This script is attached to the player and it
/// ensures that every players position, rotation, and scale,
/// are kept up to date across the network.
/// </summary>
public class MovementUpdate : MonoBehaviour {
//Variables Start___________________________________
private Vector3 lastPosition;
private Quaternion lastRotation;
private Transform myTransform;
//Variables End_____________________________________
// Use this for initialization
void Start ()
{
if(networkView.isMine == true)
{
myTransform = transform;
//Ensure taht everyone sees the player at the correct location
//the moment they spawn.
networkView.RPC("updateMovement", RPCMode.OthersBuffered,
myTransform.position, myTransform.rotation);
}
else
{
enabled = false;
}
}
// Update is called once per frame
void Update ()
{
//If the player has moved at all then fire off an RPC to update the players
//position and rotation across the network.
if(Vector3.Distance(myTransform.position, lastPosition) >= 0.1)
{
//Capture the player's position before the RPC is fired off and use this
//to determine if the player has moved in the if statement above.
lastPosition = myTransform.position;
networkView.RPC("updateMovement", RPCMode.OthersBuffered,
myTransform.position, myTransform.rotation);
}
if(Quaternion.Angle(myTransform.rotation, lastRotation) >= 1)
{
//Capture the player's rotation before the RPC is fired off and use this
//to determine if the player has turned in the if statement above.
lastRotation = myTransform.rotation;
networkView.RPC("updateMovement", RPCMode.OthersBuffered,
myTransform.position, myTransform.rotation);
}
}
[RPC]
void updateMovement (Vector3 newPosition, Quaternion newRotation)
{
transform.position = newPosition;
transform.rotation = newRotation;
}
}
Answer by jeijei · Oct 11, 2014 at 04:03 AM
you need to have rpc calls for your animations too, networkview by default only does character position im not sure how this goes like
photonView.RPC("anim", PhotonTargets.AllBuffered, "animstate");
where anim is the animation function and animstate is some parameter for which animation is being played
Your answer
![](https://koobas.hobune.stream/wayback/20220613070333im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make an animation play over RPC call? 1 Answer
Problem with animation RPC in Photon 1 Answer
unity network animation problem 0 Answers
Networked level loading 0 Answers
network.RPC behavior 1 Answer