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 /
  • Help Room /
avatar image
0
Question by OscarBrooks · Sep 03, 2015 at 02:15 AM · networkinganimator

Unet IsLocalPlayer not working

I'm quite new to Networking and i've been using some sample assets and tutorials to get started. My problem is that when I do an IsLocalPlayer check in my script that controls the parameters for my animator it only works when I do !IsLocalPlayer, as if it recognises my animator as another player.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.Networking;
 
 public class Animations : NetworkBehaviour {
 
     private Animator anim;
     private float vert;
     private float Hor;
 
     void Start(){
         anim = GetComponent<Animator>();
     }
 
     void Update(){
     
         if (isLocalPlayer)
         {
         
         vert = Input.GetAxis("Vertical");
         Hor = Input.GetAxis("Horizontal");
         anim.SetFloat("JogFWD", vert);
         anim.SetFloat("Strafe", Hor);
 
             Debug.Log("LocalPlayer");
         }
     }
 
 
 
 }

alt text

image.png (206.4 kB)
Comment
Add comment · Show 5
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 KaldrisRelm · Sep 03, 2015 at 02:23 AM 0
Share

Looking at your screenshots I see you're calling 'IsLocalPlayer' from the 'Animations' script, however I don't see that script in your 'Robot $$anonymous$$yle' Component list. Is the 'Animations' script attached to a different GameObject?

avatar image OscarBrooks · Sep 03, 2015 at 02:34 AM 0
Share

@$$anonymous$$aldrisRelm Oops! I can't believe i missed that, thanks! However this may be for another question, but now that players are controlling their own animations, they can not be seen on the other clients view. any suggestions as to what could be causing this?

avatar image OscarBrooks · Sep 03, 2015 at 02:43 AM 0
Share

@$$anonymous$$aldrisRelm okay I haven't changed anything and it is not working anymore, script is correctly attached and the setup is the same as the screenshot. do you think it may be a bug with unity?

avatar image KaldrisRelm · Sep 03, 2015 at 02:43 AM 0
Share

Glad to hear it worked for ya, I'll make an 'answer' post towards your second question.

avatar image KaldrisRelm · Sep 03, 2015 at 03:08 AM 0
Share

Try base.isLocalServer ins$$anonymous$$d and see if that works.

1 Reply

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

Answer by KaldrisRelm · Sep 03, 2015 at 02:45 AM

Towards your initial question:

Looking at your screenshots I see you're calling 'IsLocalPlayer' from the 'Animations' script, however I don't see that script in your 'Robot Kyle' Component list. Is the 'Animations' script attached to a different GameObject?


Towards your second question regarding playing animations on all players:

Players can't communicate to other players in UNET without going through the Server first. Take the below case for instance:

Player one hits space, plays the jump animation.

To sync this across all characters, the Player (using the isLocalPlayer function) would submit a Command to the Server, saying they want to jump. The Server would then send a ClientRPC (after doing some checking if necessary first) stating that the GameObject is playing the jump animation. All players receive the ClientRPC and play the jump animation for the object:

 using UnityEngine;
 using System.Collections;
 using UnityEngine.Networking;
 
 public class PlayerJump : NetworkBehaviour
 {
     public Animator PlayerAnimator;
 
     void Update ()
     {
         if(isLocalPlayer)
         {
             if(Input.GetKeyDown (KeyCode.Space))
             {
                 CmdJumpPlayer();
             }
         }
     }
 
     [Command]
     void CmdJumpPlayer()
     {
         RpcJumpPlayer ();
     }
 
     [ClientRpc]
     void RpcJumpPlayer()
     {
         PlayerAnimator.SetBool ("Jump", true);
     }
 }

You should be able to convert the above to your script, but let us know if you need any further help.

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

29 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

Related Questions

please help me fix my network animation 0 Answers

Why doesn't networking animator work with clients 1 Answer

.nameHash and Animator.StringToHash 0 Answers

Have Animator ignore parameters, pass Animation state manually? 0 Answers

NETWORK: Animator probleme. Unity 4.6.3.f1 0 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