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 PUN.

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.

Adding a new Photon Animator View to a Photon View's Observable Components at runtime

TwiiXx
2022-05-13 13:41:17

Hello there. I'm using PUN2 and I'm trying to add a photon animator view at runtime on an player.

However, when I try to add that animator view to the player's photon view observable components, I get an "Index outside the bounds of the array" error. The error originates from the PunClasses.cs ( line: 595 ). Note that this happens only if another player spawns in and not when I am alone. The same

Did I forget to do something after adding that view?

Thanks in advance for the help.

Comments

Tobias
2022-05-18 13:48:56

You may have to copy and modify the components you use now. They are not built to be composed at runtime. In this context, I mean: You add a component locally and the next time this networked object gets an update, the component will already try to read the values it expects but the controlling player maybe didn't write them (in this update yet). Adding components is not synchronized.

You could modify the components to check if "their" data is available in an update and if not, skip reading.

TwiiXx
2022-05-19 07:47:04

Thanks for the reply.

Alright, I think I understand. Something I forgot to point out is that I add that Transform View component, via RPC to all the other players, since each player skin is loaded at runtime.

If its not too big of a hustle, could you please give a hint about how to determine if the component's data is available?

Thanks

Tobias
2022-05-19 13:06:17

You can add an observable component (or modify an existing one) to send a flag / byte to signal which other components are adding their data to the update. So each update has this info.

By extension, you basically don't need an RPC to signal "this object should get component X" because the update itself would practically tell you (in said flag / bitmask)...

Back to top