I must say I’ve always liked THREE.js. It’s clean and relatively straightforward, it just isn’t a game engine. And that’s actually okay because, ultimately, I want the control of writing the game engine part myself for Lyridia. I’ve been doing some basic testing with loading assets into a THREE.js scene and it’s not hard. One thing THREE.js lacks that BabylonJS does well is exporting scenes from Blender and then loading them in the engine. I believe that with THREE.js I’m going to have to load individual assets then place them in the scene. This method should work fine but it means I will definitely have to create a scene/level editor because I won’t be able to use Blender for this. If I can do this well it will be a great asset and should allow me to separate asset creation in Blender from scene creation in my tool. It will also allow me to ensure my scenes are as optimized as possible. For instance, if I have 200 copies of the same tree in a scene with each tree just scaled and/or rotated, there’s no reason for the client (browser) to download the tree model 200 times, and if I’m writing this all from scratch I can make sure that’s the case. My next step is to load in a simple terrain and re-attach keyboard and mouse controls so that you can walk around in my new barren 3D world.
Planning and Development
A step sideways
Planning and DevelopmentSince I seem to have convinced myself that I need to rewrite the game in THREE.js instead of BabylonJS, I’m going to take a minor break from working on collision detection. As I said in my last post basic collision detection and response is working. It’s still a little glitchy and needs a lot of work to be applied generally, but since I know it can be done I think I’ll put Penrith Forest together with THREE.js and then try to get the collision detection and response system in place from there.
Collision detection update
Planning and DevelopmentWell, the short version is that I have a very basic collision detection and response system working. My test scene has a sphere that I can move left or right. If the sphere hits a triangle it slides along the surface of the triangle. I even put two triangles with different slopes next to one another and the sphere slides along one then changes pace slightly as it slides along the other. I simplified the code from the Faurby paper I was using and there’s probably some stuff I’ll find out later I’m missing, but the basic concept is working.
My next step is to generalize to code to handle meshes instead of individually defined triangles. This is “narrow phase” collision detection and is relatively expensive to calculate, so I’ll need a broad phase scheme as well. Fortunately, THREE.js includes a utility to generate an axis aligned bounding box around a mesh and these are pretty easy to use to eliminate most geometry from consideration during the broad phase.
More collision detection
Planning and DevelopmentI’m still plugging away at getting a functioning collision detection system built. So far the collision detection part seems to be working somewhat reliably, but the collision response part is still largely non-existent. March 1 is still a reasonable timeframe and even though this is slowing things down somewhat it could definitely be time well spent if I can get this working.
Collision detection
Planning and DevelopmentI’m going to write a collide-and-slide collision detection system in Javascript with a fully functioning demo using THREE.js. I’m writing here so I’ll actually do it. This will take me time. If I am very lucky and don’t get burned out immediately, I might have it done by March 1. I’m putting everything else on hold while I work on this. If I can make a general purpose collision detection system then my primary purpose for using BabylonJS will no longer be valid and I’ll probably rewrite Lyridia base on THREE.js.
Slightly better grass
Planning and DevelopmentAfter admitting I was stalling by working on putting some grass into the game, I’ve now stalled some more to improve that process. Now instead of “solid” grass I can make double sided flat grass and it shows up correctly. As a result, a chunk of grass that looks virtually identical to the solid grass but is actually made of double sided triangles has just 15 faces. I can pare that down some if I make the grass model a little simpler, so I’ll make some other grass models at some point that are just dead simple. I used the tags feature in BabylonJS to accomplish this. Flat geometry can now be tagged as “doublesided” and when the model is loaded its material type will be converted to double sided by turning off backface culling. Backface culling should remain on for most objects for performance reasons, but the ability to selectively turn it off on objects modeled in Blender is very useful.
Punt
Planning and DevelopmentI’ve been looking at the controls in BabylonJS and so far I’m not a fan. The engine does a lot for you, which is good, but it also hides a lot of the details behind poor documentation, which is not good. There’s a whole action manager system that seems very confusing at the moment. If I try to just put in a good old fashioned addEventListener for mousedown or mouseup I get very weird results. It will pick up left mouse clicks if the right mouse is down, but not otherwise, which is frustrating.
So, I’m going to punt. The controls are good enough for now and I’m going to move onto other things. Eventually I may not even use BabylonJS. I would actually much prefer to use THREE but as it’s not a game engine there are some features it just doesn’t have. Or maybe I’ll eventually figure out BabylonJS well enough to use it correctly, but I have definitely found myself frustrated by things in BabylonJS not working the way I want to and the root cause seems to be hidden from me. That sounds like some kind of conspiracy, but it’s not that. The engine just tries to do a lot for you and if you don’t use it correctly it doesn’t throw an error, it just doesn’t do what you want. I’ll come up with my next steps and post them here soon.
Better animation
Planning and DevelopmentLast night I made a simple, bad run cycle for my test character and put it in the game. I then updated the game so that the player only “runs” when he is moving. The animation is still very rudimentary in that it just starts when you move and stops when you stop. There’s no blending to make it smoothly transition between idle and running or anything fancy like that. It’s a very basic start, but it’s a start.
My development schedule from back on February 1st hasn’t gone exactly as planned. I have basic multiplayer in place, and I’ve been improving Penrith Forest here and there, but I’ve done nothing with the camera controls or jumping. Instead I’ve been working on this animation stuff. I’ve also reorganized all of the code into a format that’s easier for me to work with. I don’t really want to mess with the camera controls or jumping since both open a can of worms, but I guess I will since it has to be done eventually.
Assets for Penrith Forest
Planning and DevelopmentHere’s a free form jazz-fusion style list of things I think would help make Penrith Forest more interesting:
- A well – random wells are always fun
- A spooky tower – some spooky stuff went down there
- Rocks
- More tree variety
- Grass
- Bushes
- A stable behind the farmhouse
- Etc., etc., etc.
I’ve also decided what the game’s very first quest will be! This will probably change, but I think it works for now, but I don’t want to give it away just yet, so I’ll post about that soon.
Development schedule, 2018.02.01
Planning and DevelopmentNext steps for Chronicles of Tright: Lyridia
- Basic multiplayer support
- This will only include the ability to see other players roaming around on the current map
- Better camera controls
- Right now the camera just stays behind the player. I need to add the ability to move the camera around the player and change the pitch to look up or down. Zooming also needs to be improved so that when you zoom all the way in the controls turn into first person. Also, the camera needs to automatically zoom so that the view of the player won’t be blocked by objects in the scene. This will also prevent players from seeing the inside of assets or the under side of the terrain.
- Jumping
- The entire movement system really needs to be re-written. It works now but is very jerky sometimes. Adding the ability for players to jump may require this, but I don’t know right now.
- Continue improving Penrith Forest
- The area needs more plants, the farmhouse needs to be improved, and I need to add a gatehouse at the exit so that players are prevented from leaving until they finish the tutorial quests. Once the tutorial quests are done, the player can use the gatehouse as a transition point to the rest of the world.
There are many, many more things to get done, but this is a decent list to try and finish during the first few weeks of February. Once all of these are done, I’ll publish the very first version of the game. You won’t be able to really do anything but walk around Penrith Forest, and you’ll be trapped there, but with the features listed above in place I think I’ll be willing to call it a very early alpha version of the game.