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 Saering · Mar 15, 2018 at 11:04 AM · unity 5networkinghostingclients

[UNET] Method called on client but not on host player

Hello! So I'm currently working on a multiplayer game using the network manager, and it's basically a game where you have to keep your laser aimed at other players to desactivate them. My laser is working perfectly, but the problem I have is that the clients can use it and desactivate other players, but the host can't use it, and I have no idea why since this is the very first time I do a multiplayer game.

So this is the laser function that's on the player prefab :

 [Client]
     void ActivateLaser ()
     {
         laserTimer += Time.deltaTime;
 
         RaycastHit _hit;
         if (Physics.Raycast (m_Camera.transform.position, m_Camera.transform.forward, out _hit, Mathf.Infinity)) 
         {
             if (_hit.collider.gameObject.tag == "Player") 
             {
                 string _hitName = _hit.collider.name;
 
                 if (GameManager.GetPlayer (_hitName).isActive) 
                 {
                     laserHitTimer += Time.deltaTime;
                     m_PlayerManager.LaserHoldingScore (laserHitTimer);
 
                     if (laserHitTimer >= desactivationLaserTime) 
                     {
                         LaserHit (_hitName);
                         laserHitTimer = 0.0f;
                     }
                 }
             }
         }
         else
         {
             laserHitTimer = 0.0f;
         }
     }
         
     void LaserHit (string _hitPlayerID)
     {
         PlayerManager _hitplayer = GameManager.GetPlayer (_hitPlayerID);
         PlayerManager _hittingPlayer = GameManager.GetPlayer (this.name);
 
         if (_hitplayer.isActive) 
         {
             _hitplayer.Desactivate ();
             _hittingPlayer.DesactivationScore ();
         }
     }


(I've obviously tried to remove the [Client] attribute but it didn't fix the problem). And this is the code used to get the player ID :

 private static Dictionary <string, PlayerManager> players = new Dictionary <string, PlayerManager> ();
 
     public static void RegisterPlayer (string _netID, PlayerManager _player)
     {
         string _playerID = "Player " + _netID;
         players.Add (_playerID, _player);
         _player.transform.name = _playerID;
     }
 
     public static PlayerManager GetPlayer (string _playerID)
     {
         return players [_playerID];
     }


Thanks a lot for giving me some of your time! :)

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

239 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

Related Questions

SyncVars not updating on client 1 Answer

Network Transport Layer API does not work with iOS to PC???? 0 Answers

Unity 5 Unet Network Rigidbody Syncing - Client sinking through objects. 0 Answers

Is there any way to do automatic p2p matchmaking system via Unet? 0 Answers

[Hololens] Connecting using Unity's UNET doesn't work after the first time connecting 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