Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a prefab with BepInEx which can be instantiated by Photon? #119

Open
StupidRepo opened this issue Nov 20, 2024 · 7 comments
Open

Comments

@StupidRepo
Copy link

Sorry if this issue doesn't fit here, I'm not really sure where to put it as it is kind of a BepInEx question and also a Photon Unity Networking (PUN) question.

Effectively, I'm trying to make an API for a multiplayer game where I can add items to the game and sync them across the network however (iirc) a prefab will need to be put in a specific folder for PUN (Resources, iirc?).

So, is it possible to make my own prefab instantiable by my plugin using PUN to sync it to others with the mod? I know I'll need an AssetBundle to hold the prefab but then I'm not really sure where to go from there. Other games I know with BepInEx custom item plugins don't use PUN (e.g. Lethal Company) so I wouldn't know any open source plugins I can 'borrow' code from...

@StupidRepo StupidRepo changed the title Adding a prefab with BepInEx which will be allowed to be instanced by Photon? Adding a prefab with BepInEx which can be instantiated by Photon? Nov 20, 2024
@ManlyMarco
Copy link
Member

You have to do it the same way as you would when making the game itself, have all people run the same code and resources so that the environments are all the same.

@StupidRepo
Copy link
Author

What do you mean by that? Because what I'm saying is that the prefab itself needs to be physically in a folder in the Unity project, but as a simple modder with no access to the project then how can I add a prefab and register it to allow Photon not to complain?

Or am I being really stupid here? 😭

@ManlyMarco
Copy link
Member

Just put it in an asset bundle and load it that way.

@StupidRepo
Copy link
Author

But I thought PUN would only load things if it was in that special folder?

@ManlyMarco
Copy link
Member

@StupidRepo
Copy link
Author

StupidRepo commented Nov 23, 2024

Yeah I know that but I'm pretty sure PUN has a weird restriction on networked prefabs from ABs. Maybe I'm wrong...

@StupidRepo
Copy link
Author

StupidRepo commented Nov 23, 2024

image @ManlyMarco If you take a look, you can see (to instantiate a networked object), I would need to pass through a prefab name. Oh and, also: Screenshot 2024-11-23 at 20 47 54

I guess I could make my own RPC instantiation, but why reinvent the wheel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants