- Home /
Network Animation Layers
I've got my animations playing for the most part, but only the ones I didn't assign layers to in the character controller. Is there any way to translate the layers over to the Network Animation script?
using UnityEngine;
using System.Collections;
using System;
public class NetworkSyncAnimation : MonoBehaviour {
public enum AniStates {
Idle = 0,
BattleStance,
Run,
Walk,
WalkBack,
FlyIdle,
FlyRight,
FlyLeft,
FlyForward,
FlyBackward,
JumpStart,
JumpUp,
JumpDown,
Land
}
public AniStates currentAnimation = AniStates.Idle;
public AniStates lastAnimation = AniStates.Idle;
public void SyncAnimation(String animationValue){
currentAnimation = (AniStates)Enum.Parse(typeof(AniStates), animationValue);
}
// Update is called once per frame
void Update () {
if (lastAnimation != currentAnimation){
lastAnimation = currentAnimation;
animation.CrossFade(Enum.GetName(typeof(AniStates), currentAnimation));
}
}
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info){
if (stream.isWriting){
char ani = (char)currentAnimation;
stream.Serialize(ref ani);
}else{
char ani = (char)0;
stream.Serialize(ref ani);
currentAnimation = (AniStates)ani;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Online Rpg Animation does not work 0 Answers
Parenting over network 0 Answers
Adding an eyeblink animation layer 0 Answers
How to synchronize animation in Unity4.x 0 Answers