Hello,
I’ve been struggling with this issue ever since I started learning networking with Unity. I am making a game where players press buttons on in-game control panel to operate a ship.
It seems that all [commands] must be called by a script that is attached to the player object, is this true?
So if I have a button in game that says “turn ship right”, the player script would have to know where the ship controller is and tell it directly to turn right, which will be difficult if we have many buttons that do very different things, they would all need to be attached to the player.
SendMessage does not seem to work. I tried to generalize by trying issue [Command] on the player object that was just wrapper for SendMessage so I can interact with the buttons without having to know exactly which function each maps on the player object.
Also Canvas → GUI onClick do not work. If a client clicks a button that has an onClick that maps to the ship.turnright, the server will not hear it, and cmdturnright will not work because its not coming from the player.
What is the best way to approach this without packing every single possible button script onto the player object?