Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by athina · Jun 28, 2011 at 10:07 AM · animationssync

sync animations problem

Hello!

I am making a multiplayer game and I'm using the networkingSyncAnimation.cs script to synch my animations. I have made a script anim.js that sends the states of animations, which is this: animation.wrapMode = WrapMode.Loop;

animation["jump"].wrapMode = WrapMode.Clamp; animation["walk"].wrapMode = WrapMode.Clamp;

animation["idle"].layer = -2; animation["walk"].layer = -2; animation["excited"].layer = -1; animation["look"].layer = -1; animation["think"].layer = -1;

animation.Stop();

function Update () { if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.0) { animation.wrapMode = WrapMode.Loop; animation.CrossFade("walk"); SendMessage("SyncAnimation", "walk"); }

 else
 {    animation.Play("idle");
     animation.CrossFade("idle");
     SendMessage("SyncAnimation", "idle");

}

 if (Input.GetButtonDown ("Jump"))
 {  animation.wrapMode = WrapMode.Once;
     animation.CrossFade("jump");
     SendMessage("SyncAnimation", "jump");
 
 }
 
 


}

function Excited() {

  animation.wrapMode = WrapMode.Once;
  animation.CrossFade("excited");
  SendMessage("SyncAnimation", "excited");
 }
 

function Think(){ animation.wrapMode = WrapMode.Once; animation.CrossFade("think"); SendMessage("SyncAnimation", "think");

 }
 

function Look(){ animation.wrapMode = WrapMode.Once; animation.CrossFade("look"); SendMessage("SyncAnimation", "look"); }

And it works great. The three functions excited,think and look are called when gui buttons are pressed. Then I use the networkingSyncAnimation.cs for synching the animations. I changed it a little bit and now it looks like this

 using UnityEngine;

using System.Collections; using System;

public class NetworkSyncAnimation : MonoBehaviour {

 public enum AniStates 
 {
     walk = 0,
     idle,
     jump,
     think,
     excited,
     look
 }
 
 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));
         
         animation["walk"].normalizedSpeed = 1.0F;
     }
 }
 
 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;
     }    
 
 }

}

My problem is that only the walk and idle movements sync and the others don't. Any ideas why happens this? In my anim script I even divided the animations in layers, so the three animations that don't play have a priority. Any help would be highly appreciated. Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by gooncorp · Mar 05, 2012 at 12:12 AM

shouldnt there be another line near:

animation["walk"].normalizedSpeed = 1.0F;

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

I want to sync my animations with eachother via Animator.SetTrigger 0 Answers

PLEASE HELP with Photon! 0 Answers

Is Network.time Syncronized with other peers on the network 0 Answers

How do I sync a flashlight over the network? 1 Answer

Syncronise animation of instantiated objects 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges