It’s been over a year since Dev Update #5 and although its a big jump in progress since then, I mostly took a break from game development and focused on other things for a while. With that said I’m back working on this and this update focuses on the following:

  1. Movement
  2. Combat System
  3. Particle System


I revamped the movement system and it now works much better. I used to try to predict all entities movement in the client via different information (who the monster was following for example). But on medium to high latency connections this would cause a lot of de-syncs between Client and Server entities. I changed it so that the position shown in the client is completely based on the position simulated in the server. Since the client is simply imitating the server now, de-syncs are a thing of the past.

I still do some entity client prediction, specifically for inertia. When an entity is pushed I simulate inertia individually on the clients (as well as on the server) and compensate a bit later. So it’s technically still possible to have de-syncs as like those seen in the older videos, but it’s very rare and less distracting. I plan on doing more optimizations, like lag compensation, as they’re needed.

If you’re more interested, take a look at Gabriel Gambetta’s Fast-Paced Multiplayer series. It was very helpful to understand the best ways to implement movement on this type of games. Take a look at his live-demo.


Combat System

Previously I only had some attack animations for the player entities, but these did no damage. I’ve started working on the combat system and now entities can damage each other.

I foresee this system will increase in complexity to cover the combat types and variations I have planned. Currently melee attacks are working. The way I envision it is having multiple weapon types for the player as well as attack types for the monster entities. So I developed it in a way that supports varying:

  • attack ranges
  • attack frames
  • attack animations
  • cool-downs
  • interruptions

I won’t go too much into details of the implementation but at the moment I do simple hit-box checks on client and server based on the different attributes. A players attack is calculated in their client, but verified by the server.

The red boxes are the enemies hit-box as simulated on the server

Particle System

I decided to implement this early on to test out to what extent I can use it, as in for animations or attacks. LibGDX supports particle effects so I’m utilizing their editor and framework for it. I made my own system to suite my needs. Wayward Souls does a great job of utilizing particle effects for attacks and ambiance.

Prototype dust, attack and blood particle effects

What’s next?

For Dev Update #7, I’ll probably do more work on the combat and status systems (attacks, health, deaths, etc…). A lot of tuning on combat to make sure it feels nice and snappy. More tweaking with the AI to make sure the fights feel fair and fun.

I’m planning on making 2 other separate posts:

  • Touch-screen Joysticks
  • Workflow optimizations

Subscribe to my newsletter

Remember to subscribe to receive monthly updates about Clash Legacy!

It’s been a few months since I worked on Clash Legacy, but I’ve restarted working on it this past few weeks. I’ve updated the progress widget on the sidebar to more closely resemble current state.

Current goal is to finish up the combat system, particle system, health, deaths and respawns.
Blog Construction:
100 %
Combat System:
75 %
Particle System:
90 %
State System:
5 %

The blog was down for the better part of the year. I quickly brought it up again, however, I lost the data backup. So I had to restore the posts manually and some links are slightly messed up.

I’ll work on post Dev Update #6 in the weekend.

This update is still focused on NPC’s movement. I’ve been making tests on how the movement system should work around the limitations of a server to client connection. NOTE: The videos shown have some level of induced lag, to simulate a low connection session.

  1. Debugging
  2. AI movement


Debug HUD

I made some updates to how I render debug lines and debug information. Specifically, I setup a specific HUD for debugging which I can enable and disable whenever I need. I used LibGDX’s GLProfiler to include information about the rendering performance, such as number of texture bindings per frame and other information. Additionally, for my development environment I’m sending server information every frame to be able to compare what the actual information will be.

AI Movement

I’ve been looking into pathfinding for a couple of weeks now. After some research I tested out a simple implementation of A* algorithm and then did more research into other pathfinding algorithms that might work better for this type of game like Theta*. I then did a different type of research, I went and played similar games to test out how they handled AI movement and collisions. I opted to put a pathfinding implementation on hold for the moment and go with a dumb follow movement from NPCs. The idea is to later combine this with different spontaneous movements per monster type to improve gameplay.

Using a simple follow mechanic I am able to guess at the current position of an entity in the client. This heavily saves data and performance. It allows for smooth and responsive movement on the client side but also introduces the possibility of a desyncif the client has a bad connection. So I introduced a sanity check that corrects an entity’s position. I still have to do further testing to see how it actually plays out with many users and varying latencies.

Before/After of a fix on a speed desync


What’s next?

I’m gonna keep working on this and on collisions. I believe collisions can be a big part of the gameplay, and having them work correctly and fun important. So I’m gonna be working heavily on that.

I also want to do monthly reports to visualize the time I’ve spent on development and other interesting bits of data I’ve gathered by using RescueTime. So keep a look out for that post.

Subscribe to my newsletter

Remember to subscribe to receive monthly updates about Clash Legacy!

I didn’t get as much work as I wanted since last update, but some work nonetheless.  As I mentioned last update I’m going to be working in NPC (or non-player entities) for a few updates.

  1. Monster skins
  2. Map entities
  3. AI waypoints

Monster Skins

Here I worked on setting up various JSON files where I can define a monster type’s constant properties, such as name, speed, skin, etcetera… This will be used by the server and client to load the necessary data of a monster without needing the server to send all of the data to the client. For example, things like name and skin will usually be the same for all pig type monsters. There’s still tons to do here. A client will only need to load monster skins for monsters that might exist in the instance.

Map Entities

With “map entities” I refer to the placement of an entity’s in the world. When I need an entity to always spawn in a map instance, I’ve set up Tiled to easily add an entity object which my server can read. I can define spawn specific information through this, such as respawn time, monster type and other properties that might be useful or we want to override from the constants. This will also be used when I add procedural generation. My current plan is to not have fully generated areas but more as in many area pieces that fit together in different ways. Some of this areas will have this entity objects which will end up being different type of monsters which the server will decide at runtime.

Pig entities in map editor

AI Waypoints

Admittedly, working with pathfinding and AI is not my forte. I’ve yet to do a full research on the best way to do this given the limitations of an online game, but I’ve gotten some work done in it already. At the moment the only thing I’m showing is the random movements NPC’s will do when not aggressive or idle, you can see this in the video above. There’s things to consider here that will apply to all movement types. One of those is the collision, you have to make sure the entity does not randomly decide to try to walk through a fence. Another thing would be a it’s spawn point. Entities should be tethered to their spawn point and not move more than a defined distance away from it. We don’t want pigs wandering into the Inn. These waypoints will likely be used more as I expand the movement system.

What’s next?

More about NPCs. I’m gonna start with actual monster pathfinding, having monsters chase entities and do so by maneuvering through obstacle/collision objects. I’ll have to do more research since this needs to work in the server and all the way to the clients. I’m hoping to finish with a flexible NPC movement system so I can have a more dynamic combat system. This could allow strong monsters to juke players with clever movements and such.