Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by verenion · Jun 25, 2013 at 11:48 AM · networkinganimationslocomotion

Locomotion animation syncing across network.

Okay, I'm currently at work, so I can't get any screenshots or code examples, but I can try and explain this as best I can.

Background

I have already written my networking system - my game was originally a FPS, now I want it be third person instead - the locomotion system is fantastic for this purpose. On my local game, I can move around, stand still and look over my shoulder and all the other bits work fine. (By the way, I used the locomotion demo with the guy shooting an orb thing flying round as a base for this project). The player prefab has been modified to have its own self contained "AimTarget" so that each player SHOULD be a self-contained prefab, including the local player. This all works fine.

Player Movement I have a script to handle the movement of players. For the local player, it sends an RPC to the other machines. For remote objects, the script takes the postiion from the RPC and Interpolates to smooth the movement of the players transform - This works perfectly.

THE PROBLEM / TL:DR When I connect two players to the same server, they both "move" correctly - their positions and rotations are correct - they even aim correctly (because of the AimTarget used by the locomotion demo). The problem is the animations are not synced - when I use WASD on one of the players - the remote players object in my game copies my animation - this is a simple case of using networkView.isMine to disable my local player applying animations to ALL the players in the scene - this has been partially fixed, but the problem is now that the remote players "clones" are 'dragged' around - its as if the script is moving the player's root transform, but none of the animations like "walk" and "run" are playing at all.

I sort of know how to fix this, I need to check if the remote players clone is receiving any movement from the owner - if the owners position has changed, apply the desired animation, but I'm not sure if there is an easier or nicer way of doing this and I also cannot find HOW to change the animation states as there are lots of "weights" all being manipulated, but I cannot find where in the scripts.

I'm sorry about the description, It's a really tricky problem to explain.

Comment
Add comment · Show 2
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
avatar image verenion · Jun 25, 2013 at 03:14 PM 0
Share

Anyone got any ideas? Any help would be appriciated at this point.

avatar image Beennn · Jun 25, 2013 at 04:50 PM 0
Share

If I understand your problem correctly, to fix it you only want to have your trigger inside networkView.is$$anonymous$$ine. This trigger then sends an RPC which will be sent to all clients including the host - this will play the animation.

 if (trigger){
 
     networkView.RPC ("Animate", RPC$$anonymous$$ode.All);
     
 }
 
 @RPC
 function Animate () {
 
     //play animation
 
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by verenion · Jun 25, 2013 at 07:30 PM

I figured this out, and wanted to provide an answer to people looking for a similar problem... By default, locomotion calculated the velocity of the player an sets the animation depending on the velocity e.g. if velocity = 0, play the idle animation etc.

However, the system also by default uses the following code to calculate the velocity:

 if (m_CharacterController!=null) {
             Vector3 ccVelocity = m_CharacterController.velocity;
             m_Velocity = ccVelocity;
             
             m_AngularVelocity = CalculateAngularVelocity(m_RotationPrev, m_Rotation);
         }
         else if (m_RigidBody!=null) {
             // Rigidbody velocity is not reliable, so we calculate our own
             m_Velocity = (m_Position-m_PositionPrev)/Time.deltaTime;
             
             // Rigidbody angularVelocity is not reliable, so we calculate out own
             m_AngularVelocity = CalculateAngularVelocity(m_RotationPrev, m_Rotation);
         }
 else
 {
 m_Velocity = (m_Position-m_PositionPrev)/Time.deltaTime;
             
             m_AngularVelocity = CalculateAngularVelocity(m_RotationPrev, m_Rotation);
 }

The problem is the first if statement one - we want the system to use the transform.position, not the character controller (remember, these are REMOTE players, we don't need to control them). If you replace the last else statement with this, it should work:

 // only use the transform as the movement detection for the remote players.
 // the updatemovementforplayers script will move the remote player, and this bit
 // of code will detect the velocity and set the correct animations
         if (networkView.isMine == false){
             m_Velocity = (m_Position-m_PositionPrev)/Time.deltaTime;
             
             m_AngularVelocity = CalculateAngularVelocity(m_RotationPrev, m_Rotation);
         }


This might help someone.

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

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animations via network 1 Answer

Locomotion problem 0 Answers

Unity networking tutorial? 6 Answers

How can I make Locomotion to work over network? 1 Answer

Unity multiplayer Animations Over a network etc 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