The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Fusion.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Photon Fusion Spawning

greatsoccerman1
2022-10-21 13:51:26

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

Comments

Isaac_Augusto
2022-10-25 14:42:09

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

greatsoccerman1
2022-12-24 07:12:19

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?

Isaac_Augusto
2023-01-03 12:10:24

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

greatsoccerman1
2023-01-16 18:56:07

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.

greatsoccerman1
2023-01-27 15:15:57

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

Back to top