1 unstable release
0.15.1 | May 16, 2024 |
---|
#1007 in Game dev
124 downloads per month
1.5MB
30K
SLoC
Examples
This folder contains various examples that showcase various lightyear
features.
Each example runs in a similar way.
Running an example
There are different 'modes' of operation:
- as a dedicated server with
cargo run -- server
- as a listen server with
cargo run -- listen-server
. This will launch 2 independent bevy apps (client and server) in separate threads. They will communicate via channels (so with almost 0 latency) - as a listen server with
cargo run -- host-server
. This will launch a single bevy app, where the server will also act as a client. Functionally, it is similar to the "listen-server" mode, but you have a single bevyWorld
instead of separate client and serverWorlds
s.
Then you can launch clients with the commands:
cargo run -- client -c 1
(-c 1
overrides the client id, to use client id 1)cargo run -- client -c 2
You can modify the file assets/settings.ron
to modify some networking settings.
Testing in wasm with webtransport
NOTE: I am using trunk to build and serve the wasm example.
To test the example in wasm, you can run the following commands: trunk serve
You will need a valid SSL certificate to test the example in wasm using webtransport. You will need to run the following commands:
sh examples/certificates/generate.sh
(to generate the temporary SSL certificates, they are only valid for 2 weeks)cargo run -- server
to start the server. The server will print out the certificate digest (something like1fd28860bd2010067cee636a64bcbb492142295b297fd8c480e604b70ce4d644
)- You then have to replace the certificate digest in the
assets/settings.ron
file with the one that the server printed out. - then start the client wasm test with
trunk serve
Dependencies
~54–97MB
~1.5M SLoC