- Home /
RPC calls and animation problems
Hello, I have been working on this a bit and I am stuck. To me this looks right but I maybe using the PRC function of the network view wrong.
What I want to do is get the animation to player for all players in my network game but it only plays the waiting animation, not the walking animation as of now and it gave me this error.
RPC call failed because the function 'Walk' does not exist in the any script attached to'Jumper(Clone)' UnityEngine.NetworkView:RPC(String, RPCMode, Object[]) TetControl:Update() (at Assets/PlayerScripts/TetControl.js:106)
This script is attached to a prefab that has the model as a child, I basically created a empty gameObject then dragged the model with the animation into the gameObject.
Thanks for any help with this
//variable for model manpulation
var model : GameObject;
//basic set of animions for the game
enum AniState { Wait,
Walk,
Deployed,
Falling,
TurnLeft,
TurnRight}
var currentAni : AniState;
function Start ()
{
//get the model data for animation
model = GameObject.Find("Jumper with walking");
//defult state
currentAni = AniState.Wait;
}
function Awake()
{
model.animation.wrapMode = WrapMode.Loop;
//defult start this animation
model.animation.CrossFade("Wait");
}
@RPC
function Update () {
if(networkView.isMine)
{
if(Input.GetKey(KeyCode.M))
{
this.transform.position += this.transform.forward * speed;
currentAni = AniState.Walk;
}
else
{
currentAni = AniState.Wait;
//hide the chute
}
if(Input.GetAxisRaw("Triggers") == -1)
{
this.transform.Rotate(Vector3.up * Time.deltaTime * turnspeed);
}
if(Input.GetAxisRaw("Triggers") == 1)
{
this.transform.Rotate(-Vector3.up * Time.deltaTime * turnspeed);
}
//chose animation
switch(currentAni)
{
case currentAni.Wait:
//play waiting animation
model.animation.CrossFade("Wait");
//send the animation to other players
//networkView.RPC("Wait",RPCMode.All);
networkView.RPC("Wait",RPCMode.All);
break;
case currentAni.Walk:
model.animation.CrossFade("Walk");
networkView.RPC("Walk",RPCMode.All);
break;
case currentAni.Deployed:
model.animation.CrossFade("DeployFalling");
networkView.RPC("DeployFalling",RPCMode.All);
break;
case currentAni.Falling:
model.animation.CrossFade("Fall");
networkView.RPC("Fall",RPCMode.All);
default:
model.animation.CrossFade("Wait");
networkView.RPC("Wait",RPCMode.All);
//make him stand still
break;
}//end of switch
}
}
Answer by whydoidoit · Dec 28, 2012 at 08:32 AM
So RPC calls a function - you haven't written the functions called Wait, Walk, Fall etc - I think what you are trying to do is this:
@RPC
function PlayAnimation(animationName : string)
{
model.animation.CrossFade(animationName);
}
...
switch(currentAni)
{
case currentAni.Wait:
//play waiting animation
//send the animation to other players
networkView.RPC("PlayAnimation",RPCMode.All, "Wait");
break;
case currentAni.Walk:
networkView.RPC("PlayAnimation",RPCMode.All, "Walk");
break;
case currentAni.Deployed:
networkView.RPC("PlayAnimation",RPCMode.All, "DeployFalling");
break;
...
Thank you for helping me.
it still does not play the animation. he still slides I have a network view on both the prefab and the model in the prefab, but I think that only looks at translation and location not animation. Is there something That I have forgotten to add?
You need to just indent code by 4 spaces or 1 tab and paste it into the comments box - I can't read that. It looks like you are still passing a parameter "Wait" to your function that doesn't need a parameter...
switch(currentAni)
{
case currentAni.Wait:
//play waiting animation
model.animation.CrossFade("Wait");
//send the animation to other players
//networkView.RPC("Wait",RPC$$anonymous$$ode.All);
networkView.RPC("PlayAnimation",RPC$$anonymous$$ode.All, "Wait");
break;
.......
@RPC
function PlayAnimation(animationName : String)
{
model.animation.CrossFade(animationName);
}
This is what I have so far that have been working with but still no animation plays I have even made a new function for every animation that the model has but still not use.
Your answer
Follow this Question
Related Questions
Networked Animations Play Partially Or Not At All 0 Answers
How To Get Current Animation Name 3 Answers
Parenting and RPC functions 1 Answer
networkView.RPC() inside a ScriptableObject 1 Answer
How can I send a mouse click to a server using an RPC? 0 Answers