[Realm Rush] Pathfinding Progress on my version

In my version of Realm Rush (named Aliens&Castles in a spark of originality) I’m taking the BFS pathfinding one step further and implementing a “danger level” for the different paths depending on how many defensive towers are laid out along them. As the following gif shows for the green path, enemies will always try to look for the least dangerous, but still shortest, path. This forces players to strategize their tower placement.

Apart from regular enemies, I want to implement enemies with weapons that will do the complete opposite: calculate the most dangerous paths to exclusively destroy towers.

So far it’s looking nice!

Aliens&Castles

7 Likes

Whoa :exploding_head: You made this? It looks incredible

1 Like

Thanks, but I’m afraid the credit should go to Kenney Assets (it’s his tower defense pack) and also @garypettie for much of the code provided in the course. I’m just tweaking things here and there and “putting the puzzle together”, so to say :P.

On another note, here comes a new update. I had performance problems with enemies calculating paths upon respawn. I assigned the EnemyPathing script to the enemy prefabs, now all possible paths are calculated upon game loading (a max of 5 paths per spawning point and target tile) and assigned to the script that moves the enemies, and on enemy respawn I just loop through those paths in the enemy moving script to calculate the danger level of each and assign the least dangerous. Now there are no hiccups during play but a much longer initial loading is required.

Here is a gif with 2 enemies per spawning point and how their paths differ when they spawn again when towers are placed:

Aliens&Castles Wave

Great work @OuterGazer.
It sounds like you’ve gone and upgraded the basic BFS algorithm from the course and converted it to Dijkstra by adding some danger weighting to the paths.
You probably shouldn’t be seeing any performance issues at this kind of scale, so there may just be a few inefficiencies here and there that you can fine tune.
You may find this article from Red Blog Games helpful Introduction to the A* Algorithm

Keep up the great work and share a link to your game once everything is working :slight_smile:

1 Like

Thanks for the link Gary! I’ll chek it out. I’ll let you guys know about the finished version, of course. Although that may be in a couple of weeks still.

The performance issue comes because I customized the BFS, most probably in a not so efficient way. Instead of finishing pathfinding when the target coordinates are reached, I call the CreatePath() method recursively. I have some bools in the crossings set up, so that the chosen path out of a crossroad gets blocked for subsequent pathfindings. This forces the recursion to find increasingly longer paths to the target tile. I set it so that after 5 different paths are found it quits the recursion, so the repetition of these many loops was causing hiccups.

1 Like

Time for a new update! I’ve spent the last couple of days designing the towers and enemies with their behaviours and here is another gif showcasing them. Players will have acces to balistas, cannon and catapult towers. Enemies will have non-violent and violent enemies. Red non-violent will target the red castle at the end, white non-violent will target the purple castle more in the middle. Both will always look for the shortest, and less dangerous, path available. Violent alien enemies are balistas, cannons and missile launchers. Those will pendle between their spawn points and the target point of the purple castle back and forth always through the most dangerous path.

Hope fully this will strike a balance in the placement of towers and procure some fun gameplay. Only menus, tutorial windows, balancing and polishing left.

Aliens&Castles Preview

I haven’t had a lot of time to work on this in the last few weeks, but here is finally an update on the project. I have refactored a lot of code, fixing issues in the pathfinding and tower aiming algorithms and I have made some cosmetic advancements too; implementing a basic menu for tower selecting, showing a preview of the tower before building and adding a constructing animation. This is finally taking good form.

Aliens&Castles Preview Advanced

2 Likes

January has been busy and I have barely had time for this little project. Fortunately I’ve been able to come back on track during the last week and did some necessary bug fixing and finished all systems I needed.

Now comes the fun part, designing the waves and balancing all gameplay aspects! The gif is a possible almost end game state after approximately 35 waves. After this it’s “just” the polish and implementing the different IU window tutorials during the waves. The end is near!

Aliens&Castles Preview Gameplay

2 Likes

This is looking amazing! :grin:

1 Like

Thanks! Let’s see if I can make justice to it in the final version.

Hi OuterGazer,
this does look really cool. Looking forward to the link to try it out.
By the way, which course lesson is this based on?
Thank you!

Thanks! I’ll definitely publish a lnik to the game once I finish it and upload it. This is based on the Realm Rush section of the 3D course, taught by Gary.

1 Like

It’s done!! Next is the thread link where I have published it:

Privacy & Terms