GITHUB Link to the full open source code
DEMO Link to the latest demo build
PROGRESS POST The detailled progress post on Babylon.js forum
Technology used: Babylon.js 6.x / Colyseus 0.15 / SQLite
Hi there,
It's been a while, and much has changed.
Restructuring the server (again)
Just a quick update on the project: I’ve wasted ALOT of time on trying to restructure the server (test/yuka branch) in order to simplify and decouple the different parts (Colyseus, Yuka, Game manager, etc) and after a few different attempts and alot of work, I’ve not managed to get a solution that is as simple as having the Colyseus Schema as the main object of my game entities.
I’ve tried a few different ways:
- Having Yuka game entity as a base, and Colyseus schema as a child under it, that works but leads to more complexity and duplication and forcing me to create a sync function that runs on every iteration
- Having a custom game entity as a base, and Colyseus schema as a child but that leads to the same issues as above,
- Having a custom game entity and Colyseus at the same level and synchronize them using a specific id but that create its own complexity. So I’ve reverted to using Colyseus schema as my base game entity, in order to be able to do for ex: this.mana = 100; and it will sync automatically to clients.
Simpler is better,
Better AI using Finite State Machine
During the refactor above, I added a simple FSM state machine with an ENTER, EXECUTE & EXIT method to the enemy AI.
This is reasonably versatile and allowed to improved AI behaviour quite significantly all while reducing duplicate code.
Turns out, I only really need these 5 states:
- IDLE
- PATROL
- CHASE
- ATTACK
- DEAD
In the future, I will move from FSM to a behaviour tree, but that would be a little overkill currently.
You can find some video showing the results here: https://forum.babylonjs.com/t/open-source-multiplayer-3d-rpg-using-colyseus/35733/168?u=oriongu
Dynamic spawns
I also added a simple spawning controller, and using a basic JSON structure attached to each level, it will keep adding and spawning enemies and NPC as needed.
// will create an aggresive ennemy (attackable by player) that will patrol by cycling through each of the specified waypoints
{
type: "path",
behaviour: "patrol",
aggressive: true,
canAttack: true,
points: [
new Vector3(17.47, 0.04, 2.55),
new Vector3(31.77, 3.54, 2.56),
new Vector3(32.46, 3.54, -11.21),
new Vector3(16.87, 0.04, -8.92)
],
radius: 0,
amount: 1,
race: "male_enemy",
name: "Guard Pirate",
},
Equipping & un-equipping Items
I added the ability to equip & un-equipping and item by right-clicking on them in the inventory.
I also added the relevant UI that goes with it to show what item are equipped.
Added the Y axis
The latest addition, and a big one, is the addition of the long waited/planned Y axis to the project.
So levels DO NOT need to be flat, YAY.
Top comments (1)
You can now also equip a lovely gray shield, need to brush up my 3d skills :)