Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Versi · Sep 28, 2017 at 06:03 PM · animationscripting problemnetworkinganimatordoor

Need Help Syncing door animations between all clients!

As the title says, I require a door to be synced on all the clients (door opening and closing animations).

I just need directions on how to do that, I have looked at a few tutorials for the NetworkAnimator, but all seem to be on animating the actual character movements and not things in the scene (non-player objects) which need to be animated across the network (e.g. the door). I was, however, able to get the door with the NetworkAnimator on it to allow the host (server & client) to sync to the client however when the client opens the door, it is not synced to the host.

I also attempted to throw the whole NetworkAnimator out and use Command/ClientRPC calls to open and close the door, but all I get is "Trying to send command for object without authority." for the client attempt and nothing when the host attempts to open it (both result in no door opening).

I would like it to use the NetworkAnimator (or another way to at least start animations synced across all clients and the host) as I have things like auto-turrets which are to be triggered to unfold and start firing at players and then fold back, so I want to apply the same 'knowledge' to that if possible.

Edit: Since the project is just a testing project, tell me where I should upload the files and I can.


This is the current setup I have (The game is basically the Network Tutorial but changed with a custom lobby networking script). Where this is at is, the host when opening the door will show the animation on both themselves and the other client, however when the client interacts with the door, only the client who interacted will see the animation and the host/other client can't.

Image showing setup in scene: alt text

Image showing Hierarchy: alt text

Image Showing the "doorTrigger" with the script attached: alt text

Image showing the "door" components: alt text

This is the script attached to the doorTrigger (The one which handles the animation (opening and closing) of the door object):

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Networking;
 
 public class NetworkedDoor : NetworkBehaviour {
 
     public Animator animator;
     bool currentDoorState;
 
     void Start()
     {
         currentDoorState = false;
     }
 
     IEnumerator doorcontrolling()
     {
         if (Input.GetKeyDown(KeyCode.E))
         {
             if (currentDoorState)
             {
                 closeDoor();
                 yield return new WaitForSeconds(1);
             }
             else
             {
                 openDoor();
                 yield return new WaitForSeconds(1);
             }
         }
     }
 
     void OnTriggerStay(Collider col)
     {
         if (col.gameObject.tag == "Player")
         {
             StartCoroutine(doorcontrolling());
         }
     }
 
     void openDoor()
     {
         animator.SetBool("DoorState", true);
         currentDoorState = true;
     }
 
     void closeDoor()
     {
         animator.SetBool("DoorState", false);
         currentDoorState = false;
     }
 }
 

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

0 Replies

· Add your reply
  • Sort: 

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

242 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image

Related Questions

How to create animations that can be edited with scripts in runtime? 1 Answer

Have some minor problems. Cant tell if its a script issue or a animator issue. 1 Answer

Enable animation C# 0 Answers

Why is my Character staying in Air Idle rather than Grounded Idle? 0 Answers

Rotation Y axis is bugged. 2 Answers


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