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

Options

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
    Options

    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
    Options

    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
    Options

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