-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from cBournhonesque/cb/listen-server
update all examples to support listen-server mode
- Loading branch information
Showing
60 changed files
with
1,615 additions
and
1,041 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
# Features | ||
|
||
|
||
This example showcases how prespawning player objects on the client side works: | ||
- you just have to add a `PreSpawnedPlayedObject` component to the pre-spawned entity. The system that spawns the entity can be identical in the client and the server | ||
|
||
- you just have to add a `PreSpawnedPlayedObject` component to the pre-spawned entity. The system that spawns the entity | ||
can be identical in the client and the server | ||
- the client spawns the entity immediately in the predicted timeline | ||
- when the client receives the server entity, it will match it with the existing pre-spawned entity! | ||
|
||
https://github.com/cBournhonesque/lightyear/assets/8112632/ee547c32-1f14-4bdc-9e6d-67f900af84d0 | ||
|
||
## Running the example | ||
|
||
https://github.com/cBournhonesque/lightyear/assets/8112632/ee547c32-1f14-4bdc-9e6d-67f900af84d0 | ||
You can either run the example as a "Listen Server" (the program acts as both client and server) | ||
with: `cargo run -- listen-server` | ||
or as dedicated server with `cargo run -- server` | ||
|
||
Then you can launch multiple clients with the commands: | ||
|
||
- `cargo run -- client -c 1` | ||
- `cargo run -- client -c 2` | ||
|
||
You can modify the file `assets/settings.ron` to modify some networking settings. | ||
|
||
### Testing webtransport in wasm | ||
|
||
NOTE: I am using [trunk](https://trunkrs.dev/) to build and serve the wasm example. | ||
|
||
To test the example in wasm, you can run the following commands: `trunk serve` | ||
|
||
# Usage | ||
You will need a valid SSL certificate to test the example in wasm using webtransport. You will need to run the following | ||
commands: | ||
|
||
- Run the server with: `cargo run -- server --headless` | ||
- Run the clients with: | ||
`cargo run -- client -c 1` | ||
`cargo run -- client -c 2` | ||
- `sh examples/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 | ||
like `1fd28860bd2010067cee636a64bcbb492142295b297fd8c480e604b70ce4d644`) | ||
- 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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.