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 /
avatar image
0
Question by Heartless49 · Mar 01, 2011 at 05:45 PM · networkingmultiplayerreference

Reference to local player on multiplayer?

I have been looking for an answer to this for a few days now, and haven't been able to figure it out. Even after trying the forums and IRC, I've come up with nothing, >.<

I've got an object, in my multiplayer game, that uses an OnMouseOver function to show it's information as a toolTip for the player. Now, when this is happening, the player's script needs to know that it's mouse is over something that is interactable. This is done in the player's script with a simple mouseOver boolean that is switched to true.

My problem is, I cannot find a way to reference the player's script with the object's script, so that it knows to change its variable. It is a multiplayer game, with multiple players, as well as multiple of these types of objects on the server, each of which use the same scripts. This being the case, all I need is a reference to the local playerController so that I can get their script component to change the variable.

I read a few things about using Network.player with an array of playerController gameobjects, but after plugging that into my project, Unity now crashes whenever my mouse goes over one of these objects... so I'm guessing that it probably won't work, or I'm not using it right, lol.

I've have had people explain to me that I just need to assign each player an ID number of some kind and use that... but what they don't understand is that it's not a matter of ID's, its just finding which player is initiating the OnMouseOver of the object.

Now, the OnMouseOver function, unless I'm mistaken, is only readable on the local client... so if another player mouses over an object, my client won't know that. This being the case, I believe I could just find the localPlayer gameobject, and use reference that.

If anyone has any ideas, I would really appreciate it - I'm not looking for a whole script or anything, just trying to find a way to get this reference, xP

Thank you, in advance, ^^

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AKAssassin · Apr 13, 2011 at 05:50 PM

So do you want when the other players mouse over something for all players to see a tool tip about it or do you only want each locally to see the tool tip when they mouse over something?

Comment
Add comment · Show 1 · 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
avatar image DESTRUKTORR · Jul 04, 2012 at 06:18 PM 0
Share

"all I need is a reference to the local playerController so that I can get their script component to change the variable."

It's pretty clear that he's looking for a way to discern which specific player (or players) are actually attempting and able to access a specific object for use, and reference that specific object.

In other words, he wants to make sure that when a player has their mouse over an object's collider, that if another player, who didn't have their mouse over the collider, wouldn't get the option of "using" said object, given those conditions, and that it specifically targets the client of the player(s) who CAN use it, and nobody else.

avatar image
0

Answer by DESTRUKTORR · Jul 04, 2012 at 10:26 PM

I'm fairly certain that OnMouseOver is handled locally, which means it would only be when the local player mouses over the object that the script inside were triggered, and it would only do this from their machine. Potentially, if you wanted to, you could have that trigger scripts on the other player's machines, but that's not exactly what you were looking for so I won't go into much more detail on that.

However, in order to ensure that the properties are being changed on that specific player, you may want to contain them in one of these blocks:

 if(networkView.isMine)
 {
    //Whatever you want it to do
 }

Or you may want to start fiddling around with NetworkPlayer.ipAddress.

Which of these methods you should use (if not both)depends entirely upon specifically how you've set up your network, and how you choose to go about accomplishing that goal.

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

1 Person is following this question.

avatar image

Related Questions

Unity networking tutorial? 6 Answers

NetworkBehaviour has an "isLocalPlayer" boolean, but is there a sort of "localPlayer" G.O. reference? 0 Answers

Can I use the Unity networking HLAPI without paying for the Unity Multiplayer service? 0 Answers

Errors when restarting the NetworkManager 3 times 0 Answers

[Photon] Restart scene rpc doesn't work 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