Sunday, 14 February 2016

PUN shooter #2 - Player prefabs, Web Player and WebGL

Customising player prefabs (~2 hours)

Today I focused on providing a different character for each player.
My asset provides Mecanim prefabs. Let's not convert everything to legacy and use this. No need to setup a state machine. Mecanim's Animator does support Play(string).

My setup uses model/view decoupling. So what I send to PhotonNetwork.Instantiate() is the model prefab (containing the logic), then I select a view prefab (containing the mesh and animations) and instantiate that locally.

So, how to make this view the same across the network? Well. PhotonNewtork.Instantiate() allows an object[] as parameter. This you can retrieve from PhotonView as InstantiationData upon handling OnPhotonInstantiate. 

WebGL build (~2 hours)

For better and for worse, it's the future.
In the meantime, WebGL is new tech. Neither Photon nor UNET totally play nice with it
(See Q&A here).
  • Photon chat will generate an error (comment out the code is okay... if you don't use Photon chat I guess).
  • Uncheck 'run in background'
  • Uncheck 'strip engine code'
At the time of writing, my Photon/WebGL builds crash in Safari and Chrome.
Also, a WebGL build takes 20 minutes on my 6 years old laptop. 

Never mind bugs that may or may not be fixable, it would take a fair amount of automation to smooth this enough for daily or even weekly builds so I guess I'll stick to the deprecated (before the new stuff even works?) web player.

Web Player (~20 minutes)

You can try it [here] (bring your friends)

No comments:

Post a Comment