I am trying to find out a way to distinguish between players by getting the player ID (gameobject?) of whomever is clicking an item and place it into that specific players inventory. My problem is not being able to find out which player is clicking with the mouse (if it was OnEnterCollission it would be easier to find the name of the gameobject entering, thus which player). Anyone have a simple solution for this?
Appreciate any working solution for this problem, and if you need more information let me know
// ----------------------------- // Example code of usage: // void OnMouseEnter() { // Example mouseEnter = true; } void Update() { if (Input.GetMouseButtonDown(0) && mouseEnter) { // Do stuff here and add items to the player that clicked! } }
Let me rephrase in case people didn’t understand my question;
“How do I get the specific Player’s reference from the player that clicks (Cursor in an 2D environment) an item? (assume there are more than 1 player)”
Nothing is set yet - this is preperation for multiplayer implementation, so none specific.
Any recommendation of networking middleware (I don’t even know what that is) is appreciated!
Photon would be good if you’re a beginner. The thing is, every middleware defines players differently so you can’t implement this before you know which you’re using.
For example, Photon defines players with the PhotonPlayer class while DarkRift defines players with an integer ID.