How to send a GameObject id to the server

Bugfixr
Bugfixr
edited March 2017 in Photon Bolt
In my game, the user interacts with various objects. How can I notify the server which object a user wishes to interact with? In my case, the object may not be a BoltEntity, but will instead be a regular GameObject added to my scene.

I'm using an authoritative server and sending a command to perform the interaction.

Comments

  • Use an event or add to the player command, if you have a more specific use case I can answer more specifically
  • Bugfixr
    Bugfixr
    edited March 2017
    Ok, here's a use-case.

    A player-controlled character, owned by the server, left clicks a prefab in the scene. Using a raycast, I'm able to determine what Gameobject was clicked (in this case, let's assume it was a stone the user wishes to pick up). The user then issues a "harvest" command:

    public class PlayerController : Bolt.EntityBehaviour<PlayerState> { GameObject harvestTarget; // set this when the user left clicks on a world gameobject public override void SimulateController() { var harvestInput = HarvestCommand.Create(); harvestInput.gameObject = ? // What do I assign this to? entity.QueueInput(harvestInput); } }
    1. What do I send as the gameObject (i.e, what type of "input" is it)?
    2. When I get the value in ExecuteCommand, how do I use it to know what the correct GameObject is on the server?
  • You either want to send a unique identifier for it, whether a sibling index or a GUID. Then on the server once you receive the input you check to make sure that specific gameobject that you look up using the ID, check this distance etc to make sure they're allowed to, and then pick it up/ add to inventory/etc