Photon Fusion Spawning

Options

I am working on a tower defense kind of game. In this game the client and host need to build towers and see that each other has built towers. I am having trouble with the client being able to build towers. Runner.spawn() does not work with clients because it cant just build a tower any time a mouse click happens. it has to be after a tower was selected and in specific spots. I can kind of get it to work if I used network inputs, but this does not work correctly.


Can someone PLEASE help me??? I just need to know how i can get the client to be able to build a tower or spawn objects. Is there a server setting the host can set when setting a room?


Also, this needs to be a Host/Client server. I dont want the client being able to spawn their own versions. Every game object needs to be synced on the network

Answers

  • Hi,

    Client's cannot spawn object, they can only do predicted spawn, but that's not what you're looking for.

    You would need to use Inputs or RPCs for that. That's how state transfer works, the Host/Server has the state authority and clients can have input authority over objects.

    Please take a look at the Fusion tutorials and the Samples provided.

    -----

    Isaac Augusto

    Photon Fusion Team

  • So the way it works is you select the unit you want to build then select on the tile you want to spawn it on. when you click on the tile that is when the input would need to change.


    so say you want to build a footman then you click on square A1 how would you transfer that to input??

    I cant do if (Input.mouse(0) because the player can click the mouse without having selected a unit to build or after selecting a tile to build on.


    Can you call methods in the InputPoller to enabled flags? so then when the input goes through the next network update it picks up that the flag bool is set to true?

  • Hey,

    Not sure I followed, but let's say that you have a defined amount of possible units that you can store in an Enum, you could send a RPC to the server passing the unit index and the position you're going to spawn it.

    Personally, I would use RPCs for specific actions like these instead of Inputs.

    -----

    Isaac Augusto

    Photon Fusion Team

  • I think you are following. If I click on square 1A I need it to spawn at that square. From what I was reading though there would be a little lag from the user clicking the square to spawn the unit until the servers spawns the unit. From the Fusion documentation it recommends using inputs for predicted spawning. I was trying to use RPCs the first time but rewrote the code when I read about predicted spawning.

  • @Isaac_Augusto Will RPCs be the right thing to use? since im trying to keep things sync'd up with no delay?