Passing default state values after Instantiate

Hey Guys,

Hopefully this is pretty simple to solve, but I've not been able to work it out.

Here's my problem... I call

myEntity = BoltNetwork.Instantiate(...) to spawn the entity, then use

myEntity.state.Scalar = scaleValue; directly afterwards, to set a default value that is applied to other (unsynced) attributes of the instantiated object during the Attached() call.

This doesn't work. Scalar is always 0. My question then is how do I set a default value for this state variable at instantiation?

Any help is much appreciated.

Danny

Best Answer

Answers

  • JohnTube
    JohnTube mod
    edited November 2021 Accepted Answer

    Hi @allnodcoms,

    Thank you for choosing Photon!

    You could make use of custom instantiation data to pass initialization values.

  • Cheers John,

    I have to confess, I dropped by the Discord and was helped out by @SmakTalk.

    I use IProtocolTokens during setup, for passing player names and such, but I must have missed the overloaded Instantiate() call that accepts one. Using tokens to synchronise initial values is most definitely the way to go.

    Thanks again. I may well be back ;o)

    Danny

  • Oh sorry I totally missed that you're using Bolt and not PUN. So my answer is completely out of context and wrong.

    But I'm glad you got help on discord.