v00004 (2018.06.23)

Release Announcement

Lyridia v00004 (2018.06.23) is now live.  Here are some new features in this version:

  • Improved enemy movement and control.  The boars now won’t walk through trees and move around somewhat more naturally.
  • Better animations.  Admittedly, they’re still bad but when you move it now looks at least a little like the guy is running and there is an idle animation and an attack animation that triggers if you press ‘1’.

That’s a pretty short list but getting animations to work from Blender to THREE.js has been just this side of a nightmare, so hopefully the next steps will be easier.

Improving animations

Planning and Development

The alternate Blender glTF exporter seems to be working great.  I exported my player character and the actions defined in Blender showed up just fine.  After some fiddling I was able to get those animations to play in Lyridia.  So I now have an idle animation, a run animation, and an attack animation.  The idle animation plays when you’re, um, idle.  And the other two are self explanatory as well.  Right now the attack is just a sort of punching motion and it’s not very expressive.  I think I might give the character a sword and modify the attack action just so that it’s more obvious what’s happening.  Once that’s done, I’ll definitely release a new version, so look for that this weekend.

There are definitely big parts of the animation system in THREE.js that I don’t understand at all right now.  I tried using the crossFadeTo function but had absolutely no luck getting it to work.  Presumably it can be used because there are examples that use it, but I may punt on that issue for now just to keep moving forward with more substantive game features.

Still struggling along

Planning and Development

The animation pipeline from Blender to THREE.js is just horrible.  I want to use the glTF file format because that seems like it will be supported the best in the future but the official Blender exporter from Khronos Group doesn’t support multiple animations.  I’m not sure how that’s not a core feature, but apparently it isn’t.  I found another exporter plugin that seems to play more nicely.  I was able to create a very simple scene with a cube that just moves around, but it’s movement is defined by two different actions in Blender and the export to glTF is actually working.  I’m really disappointed in how kludgy this whole process is, but these standards are all rapidly changing so hopefully the official exporter will be updated soon and maybe things will be a little clearer to me as well when I’ve spend more time creating animations in Blender.  In any case, I’ve seriously wanted to just rage quit the whole project several times over this, but maybe I can just barely, barely see the light at the end of the tunnel for this process.

Even more animation frustration

Planning and Development

I’m at the point where I need a reliable method to import animated assets into Lyridia.  I’ve been back and forth with several different options from the THREE.js native JSON format, to .fbx files, to glTF files.  I currently don’t like any of them, but it seems like glTF will have the best standardization and support going forward, so that’s what I’d really like to use.  I’ve been using .fbx files but I’ve noticed that the animations I’m creating just don’t look right.  It’s like what is shown in the game is a watered down version of what I see in Blender.  I realize that makes no sense, but that’s what I’m consistently seeing.  As a test I made an animation where the player’s leg raises up to the side at a 90 degree angle.  In Blender it comes right up to 90 degrees then drops back down.  When I export the animation to a .fbx file and play that same animation using THREE.js, the characters leg only goes up about 60-70 degrees.  That makes absolutely no sense to me, but I can see it with my eyes.  Fortunately the glTF exports seem to be better, but importing .glb files into THREE.js is a process on its own and has the whole game broken at the moment.

As much as I was looking forward to putting out a release in the next day or so, I feel like I just have to spend the time to figure this out now.  So I’m going to take at least a few days and set up a .glb importing test environment so that I can figure out exactly how to export the animations from Blender and import them into THREE.js.  The joys of using rapidly evolving open source tools.

Improved boar control

Planning and Development

I looked at the development server world today and could only see maybe 3 boars wandering around where they were supposed to be.  I obviously had a problem with the control code so I went and looked and the check to keep the boars inside the spawn area was just wrong.  I fixed it, but it was funny to walk around and see the boars so spread out after just randomly moving around for many hours.

I also made the boars not move on every single update.  Now a random selection of about 10% of the boars move on each update.  It still isn’t totally natural looking, but it’s much better than having every one move at regular 1 second intervals.

According to my schedule from a few posts ago, I just need to get a somewhat decent attack animation in the game and I’m ready for a release.  I’ll work on that tonight.

Exclusion zones

Planning and Development

I’ve been pretty busy the last several days so I’m just getting around to implementing this but it looks like my exclusion zones are working.  After watching for several minutes it does not appear that the boars will walk into the cylinders surrounding the trees that were created in the map editor.  This took some wrangling as the collision zones are actually children of the enemy spawn point itself, so getting the correct coordinates to check against took a little fiddling, but it seems to be working.  One thing the code does not do at this point is check for paths through an exclusion zone.  That is, if a boar tries to walk from a point outside an exclusion zone that goes through an exclusion zone but stops again outside the exclusion zone, it won’t be stopped.  This isn’t an issue right now because the maximum distance traveled at each update is only 2 meters and the exclusion zones all have radii of about 5 meters, but eventually this will need to be improved.  Now I need to make a small improvement to make the boars move around just a little more naturally.

I’ve been working on some new animations for the player character so hopefully I can get those put in by this weekend and release a new version at that point.

Editor improvements

Planning and Development

I’ve been working on exclusion zones in the world editor and this is what I have so far:

Right, what is this?  This is Penrith Forest a little away from the farmhouse in among some big trees.  Near the middle of the screen you can see a tiny little boar.  It only looks small because the camera is pretty high up.  That boar is the center of the yellow cylinder and that represents a wandering zone for the enemy at the center, in this case a boar.  Eventually I’ll need to configure how many enemies to keep in the zone, but not now.  The blue cylinders are intended to be “exclusion zones” where the boars will not walk.  This is computationally less expensive than having the boars move around with standard collision detection turned on.  You can imagine that it’s really easy to determine whether a point or path is within one large circle and not within a few smaller circles.  Since I need to control movement only in a very general way it make sense to do it the cheap way.  Of course, this is more work on the front end.  I have to actually define each of these zones but as long as the tools in the world editor work ok it’s not too bad.

Next I’ll need to update the server code so that boars won’t walk into or through an exclusion zone.  That should be fairly simple, I hope.

Roadmap for the next few weeks

Planning and Development

Here are the things I want to get into the game next, hopefully in this order:

  1. Add exclusion zones to enemy wander zones.  This is needed so that enemies won’t walk through trees and so forth.
  2. Improve enemy wandering algorithm so that movement is more natural.
  3. Improve player character animations.  Specifically, I’ll need better idle, run, and attack animations.  [Release new version here.]
  4. Let players attack boars.  Initially the boars won’t attack back, or even react to being attacked but attacking boars should eventually kill them and a new one should respawn.  [Release new version here.]
  5. Create the beginnings of a HUD to display very basic character information and stats.
  6. Create an NPC dialogue box system.
  7. Create a very basic quest system.  [Release new version here.]
  8. Fix collision detection and add in gravity.  [Release new version here.]

That’s a pretty good list for now.  I’m guessing this is a month ore more, so I’ll keep referring back to this list as I add features.  Nothing new tonight, though, because I’m beat.

Boar movement

Planning and Development

I finally got the boars to face the correct way as they are moving around.  Sometimes I get a little turned around when I have to do straight up trigonometry, and that’s what this was.  Here’s what worked (in pseudocode):

var o = boarObject;

var currentPosition = ...

var newPosition = ...

var direction = newPosition - currentPosition;

o.rotation.y = Math.atan(direction.x / direction.z);

It took me an embarrassing number of tries to get this right, but it’s working now.

***

Edit: After I was sure this was working, I fired up Lyridia on my second test machine and it was still completely broken.  I fumbled around with it for some time before I found a Stack Overflow post that recommended using lookAt.  Instead of trying to calculate the rotation myself based on the direction vector, now I just tell each boar object to lookAt(newPosition); and it works great.  Internally THREE.js must be doing what I was attempting to do, but the THREE.js code actually works, so I’m going to let it handle it. 🙂

***

I had a few hours in the car today to sort of plan out the next steps for Lyridia.  I don’t want to get into all of it now because it’s late, but I’m at the point where some more “game” type functionality is going to be added soon, and once there is something for a player to actually do I might start hunting around for alpha testers just to get somebody on the site.  Exciting stuff.

More boar control

Planning and Development

It turns out last night my boars were spawning in the right place but my world editor wasn’t saving the spawn point correctly.  Once I saw that getting the editor to place the spawn point properly made the boars spawn in the correct place.  I feel like I need to write the word “spawn” a few more times.  Now the boars wander around under the trees where I wanted them.  The server side code is an absolute mess right now, but it is technically working.  Next I need to make the boars point in the direction they are walking.  I may not get that done tomorrow, but hopefully by Thursday we will have pigs facing where they are moving.