Forums » Your showcase, tips and tutorial discussions »
Using an avatar for multi-user experience !
Added by jitesh over 3 years ago
I want to use the bipbot in StartPark as an avatar ... for every user that logs onto the park that i am creating.
This is similar to the bear that was used in the stress-test.
How do i enable that ??
Also , what is the procedure if i want to use my own model as an avatar ??
Thanks,
Jitesh
Replies (5)
RE: Using an avatar for multi-user experience !
-
Added by Craig Presti over 3 years ago
Hi Jitesh,
The theory behind the multi-user functionality in VastPark is that some elements have the ability to be network enabled. A network enabled element has an owner who is responsible for updating the state of that element. When the state of the element changes and it was a change that occurred on the owners client, that change is propagated over the network.
In practice, you need to do the following:
1. Create a new script called OnNetworkConnectionEstablished
2. Inside this script, we need to dynamically inject an IMML element into the scene which is owned by that user. This will represent that user's avatar and can only be done once the NetworkConnectionEstablished event has fired.
3. When the IMML has successfully loaded (including the model) the callback script is executed where we assign the avatar and chase controllers. Call the callback script OnAvatarLoaded
4. Create a trigger for the Event NetworkConnectionEstablished and target it at your script created in step 1.
I've done the above in the attached park, take a look and have a go at adapting it to your needs. I haven't actually tested that it works, so your mileage may vary...
Edit: Updated the attached file, hard-coded FPSController long gone :)multi-user-basics.imml (5.4 kB)
RE: Using an avatar for multi-user experience !
-
Added by jitesh over 3 years ago
Thanks Craig,
I downloaded the muti-user-basics.park and went through the scripts OnAvatarLoaded and OnPlayerJoined
I tried running the park file but [color=red]it only shows an empty park[/color]
I guess it fails to load the bipbot avatar
As directed by you , I also tried using Ted as an avatar by modifying the OnPlayerJoined script but it just doesnt seem to work.
Please help
:-)
RE: Using an avatar for multi-user experience !
-
Added by Craig Presti over 3 years ago
Ah sorry, I should've mentioned that the NetworkConnectionEstablished event currently only gets fired by the Browser when connected successfully to a VastServer.
To see the park in action, you'll need to host it using VastServer and connect to it using the Browser. The expected result (if I've coded it correctly ;)) is that there will be a 100 sq. m box, 1m high that forms a walking surface and the players will appear 10m above the origin.
I realised I made a minor mistake in the original park, so please re-download it before trying again.
RE: Using an avatar for multi-user experience !
-
Added by Erencie over 2 years ago
Hi i'm trying to use the "multi-user-basics.imml" but it cannot work:-(
I'm opening a server and player to test it. I also try to replace the avatar uri as Ted's. All failed.
Can someone explain to me what's the purpose of "NetworkConnectionEstablished" trigger? Is it placed in client only?
RE: Using an avatar for multi-user experience !
-
Added by Craig Presti over 2 years ago
Oops, that one was using some deprecated code, I've updated it, give it another try as is and let me know if this one works. I've not tested, just pulled from the repository.
NetworkConnectionEstablished is a global trigger that works on client and server. Anytime a client joins the network scene, the event is fired and the clientId, alias and document the client has joined is sent across to all clients in the scene (including the server-side client).
If you look at the IMML in that attachment, you'll notice it test's to check that the connection event isn't firing because of someone else joining the scene. We only want to create an avatar for the local client that they own.
(1-5/5)