I’m trying to get a hang of the new multiplayer stuff from 5.1 and so far I’m very impressed. I would call it easy to implement but a bit hard to grasp. Anywho…
So I have this non-player object that is controlled/owned by the server and is synced to the clients. I am then trying to run a command from a non-server client on said object.
As I understand it I am only allowed to send commands on the clients own player, so is there some other way to do this?
In the HLAPI non-player objects are owned by the server. You can’t use a command from a non-player object. You could have the local player on that client do the command, then route it to the object on the server.
Ok, that will probably work, but I would prefer not to have it set up that way, but I assume that’s the only way to do it then?
Thank you for the help!
What sort of command do you need the NPC to perform that requires it must originate on the client? Probably better if most of the simulation, i.e. the game logic for things like NPC AI, takes place on the server, and is then sent to the clients.
Right now I have bullets that are instantiated locally for a client and then I just want it to send a damage event on the enemy it hit. (its a 2d game and the bullets are gameobjects)
My thinking was that since there will be so many bullets and that I want to avoid having to depend on the server to fire bullets, that each client is responsible for their bullet and only reports what they hit and doesn’t sync each bullet.
That is not a very secure model Any client could send fake damage events to the server.
Another model would be to fire the bullets on the clients and on the server, and only have the server version of the bullets do damage events. Look at the Presentation10 sample, and the Unet presentation for an example of doing damage like that: