How to: Send an event from server to a specific client?

It seems standard events will be sent to all clients. Which could work, but would be wasteful.

I imagine I'll need the BoltConnection of the client.


  • I think I've answered my own question. It's possible to send a bolt event to a specific client (from the server). When you Create the event you can pass a BoltConnection.
  • Yup. Off the top of my head.

    entity.controller is bolt connection of client (only on server this works)

    var your_event = YourEvent.Create(entity.controller);

    also, I am certain that if the entity.controller is null (server player) it will send the event to the server player.

    But if you want a client to send an event to another client.
    Client A sends event to server with Client B entity.
    Server will route/send event to Client B with entity (from Client A)
  • @dmg So sending an event from client to client takes two events, right? I don't need this functionality at the moment, but it would be nice to know for later
  • You could use the same event if you want.
    You pretty much use the server as a proxy since clients have no direct access to each other.

    Client A -> Server -> Client B
  • Okay But how should Client B recieve the event
  • Hello,

    Please, take a look on our dedicated page about Bolt Events:

    Ramon Melo
    Photon Bolt Team
  • nhunter
    edited September 2020
    I read docs in the link above + watched tutorial. There is no example. How to create Event - clear. How to send - no. Should I check like "isServer". Should I write an event receiver on the entity? For example host press button->host changes integer variable in Player entity to 1,2 or 3. A very simple example, why there is no explanation. If the topic was clear in docs, no one would ask, maybe you should add smth like this in docs.
  • Upd: after one hour searching forum I found post with this command:
    //Find all objects for the leaving connection.
            EntityObjects = new List<BoltEntity>();
            foreach (BoltEntity item in BoltNetwork.Entities)

    And it helped me alot.
    So u should create script on GameObject (i call it ServerManager) with event(Event creating is described in bolt docs) launching code:
    public void testEvent(){
    if (BoltNetwork.IsServer)
                var myEvent = _setClass.Create(EntityObjects[0]);
                myEvent._newClass = "civilian";
                myEvent = _setClass.Create(EntityObjects[1]);
                myEvent._newClass = "miner";
                //var myEntityEvent = _setClassForEntity.Create(entity);

    and on Player entity:
        public override void OnEvent(_setClass evnt)
            if (entity.IsOwner)
                state._class = evnt._newClass;