„Age of Total Heroes” - Custom RTS System

Replication model doesn’t fit RTS.
Good luck when you go multiplayer with this, without fixed point math integration into the engine and using the replication system.

Thanks for the support :smiley:

To be honest I’m a big RTS fan, but don’t like multiplayer RTS games at all. I prefer long play and strategic complexity, so my main focus is on single player vs. AI players. Moreover, there are a few (exactly 2) UE4 RTS games out there with multiplayer support (apparently with small unit quantities), >probably< using replication, so I will test it when its time is coming… Luck is definitely needed anyway.

This looks like an very interesting project. I’m also a RTS fan and even though you have mentioned that it is a single player vs computer or AI type of game i strongly suggest that you consider multiplayer as there is nothing more challenging then to play another person.

I see there is a big demand on multiplayer support, so I’m “running a background thread” in the development examining the possibilities and try to add new player functionalities by taking these into account. But it will definitely require a full code revision of pathfinding and unit/group updates = blood and tears :slight_smile:

amazing, can’t wait to see more

NEWS and VIDEOS

Hi all,

in the last hot summer weeks, the development went fine, there are a few main things to highlight:

**Group cohesion enhancement
**
Because of a unit target positioning issue experienced months ago, which made group movement stopping a bit and hesitating on building entrances (too frequent and imperfect selection of new boss unit for the group), group movement in complex environments was heavily tested, mainly in wall-stair-gate combinations, where groups should form a long snake shape, and follow the same route. The effect of cluster and group size on pathfinding quality and performance was also measured and evaluated, and the ideal building cluster size found to be the bigger the better, just contrary to group size.
Finally, it led to eliminating the wrong behavior by a few-lined weighting calculation, and the result is really great group cohesion, close to the results achievable by vector field pathfinding approaches only.

wall test

gate stress test
https://youtube.com/watch?v=69B0nwxzehA

*Vector field pathfinding prototype
**
Mentioning vector field pathfinding and movement is not accidental, it has been implemented and under testing currently, because in future it could be a performance effective replacement of the current A
tile pathfinder system, as it suits well in the current hierarchical approach. One problem is the increased number of unit-unit collisions, and the other is maintaining the group formation shape, so some kind of flocking should be created to handle both issues…

**3 ways of character customization
**
Another main task was to create a solid C++ basis for unit character customization, and establish the necessary actor components and animation notify states to handle weapon throwing and bullet shooting, that can be easily handled by artists. Three weapon attaching approaches have been implemented:

  1. Multi-mesh skeletal mesh, where material sections can be hidden/shown as needed by an animation notify state e.g. on throwing the javelin section. It has the highest performance, but has the lowest customization possibilities.
  2. Using sockets and attaching to them separate static mesh components as weapons has a bit higher performance cost, but allows great customization possibilities. The weapon components can be set hidden/shown similarly to the material section approach, but weapon component meshes can be reloaded runtime to change the weapon mesh e.g. when a technology upgrade happens.
  3. Weapons with skeletal animation using the same skeleton as the unit character, can result in high quality animations, but needs more performance. The customization possibilities are similar to the socked attaching approach.

**
multiple weapons**

https://s26.postimg.org/wsxatgpah/RTSUnitWeapons.png

complex units

https://s26.postimg.org/mqx4h2vrd/RTSUnitComplex.png

show/hide projectile weapon component on projectile weapon actor spawning

https://s26.postimg.org/584h277rd/RTSProjectile_Weapon2.png

**Improved movement and collision system for large units
**
The pathfinder supports by default 4 capability categories (e.g. infantry, cavalry, siege units, ships), and in each category units can have different size measured in tiles (normally. 1x1, 3x3, 5x5 for ground units, ships can be larger and asymmetric). Because of performance considerations, a simplified push-bounce collision system is used, and it is extended for better large unit support.

In the future you can expect further blog posts describing the above mentioned topics separately, in more details.

News #4

NEWS #4

Hi again,

last month has been spent on refining existing systems, and also new interesting features are established. No new videos are planned until a nicer and more exciting test level is made, so just shortly:
**
Improved large unit support**
Beside taking into account a unit’s area size in short range tile pathfinding, now both size and height of units does matter, and stored in clusters to be used by the long range pathfinder to enable/disable giants to pass through gates etc. Currently only buildings provide height data, but it can be extended later for other objects.
Moreover, the push-bounce collision system was also reworked to produce better and smoother movement appearance, resulting in no need of lodded AI, i.e. no more cheating: far units can move with similar precision as close units, which will be really beneficial if multiplayer support is added.
**

https://s26.postimg.org/tq7oy59u1/RTSLargeUnits.png

**
**
Movement prediction**
A new data map is introduced to help units to avoid collisions, which is really useful in crowded environments to save a lot of worthy CPU time, and to have more realistic movement.
**
More unit orders and states**
Units now can walk, run, advance, charge, stay idle, stay ready to fight, shoot, fight, or be killed, using an expanded animation state machine, taking into actual unit movement speed and the order recieved from player controller. Ladder climbing and dying states are also coming soon.
**
Unit pathfinding in background thread**
The expensive pathfinding calculations are now made in asynchronous tasks, which decreases the game thread CPU load, resulting in slightly better overall performcance.
**
No far LOD flipbook units needed**
Recent UE4 versions have been found to run with skeletal mesh only characters faster than earlier. Flipbooks require relatively high CPU and rendering performance, and would need an additional update loop on each client when multiplayer support added, so their further development is not planned.
**
Balanced group update**
It was not perfect, so has been reworked, and now update frequency and game performance is well-harmonized. It had also a good effect on the quality of group movement.
**
Group create / split / merge, and mixed unit groups**
The player can now easily disband existing groups, or create them from individual units, or merge groups and units into one large group. It also allows to have mixed unit types within the same group, resulting in more realistic army look, and improved battle tactics. The different unit types are not positioned according to their weapons, but will be solved in future.
**

https://s26.postimg.org/t1yuf7b49/RTSMixedGroups.png

**
**
Pathfinder data generation in background thread**
Earlier the editor and the game thread freezed for 10-15 seconds because of the heavy load, now long operations run in a background thread. Some parts e.g. actor manipulations should use the game thread, it will also be split into more pieces and spread over several frames in near future. This way, level loading, and data generation of procedural maps will keep the game responsive and the users happy.
**
Building destruction**
The pathfidnder data now immediately recalculated when a building is destroyed. It is going to be a damage and destroy system soon, with easy to use particle effects.
**
Towers and container buildings**
The latest exciting feature is the introduction of container buildings (like town halls or towers), which can contain several units or groups. By using portals, they are a performance cost effective way of hiding large stairways inside towers as part of a castle wall system, thus a game like Stronghold can be easily achieved. Of course visible stair and ladder systems also can be used safely. This system will be also used for siege ladders and siege towers in future, and later for ships transporting a lot of units.
**

https://s26.postimg.org/rbkergiyx/RTSTowers.png

**
**
Improved unit defensive positioning on castle walls**
A new formation positioning has been introduced specially for walls and towers, enabling units to take better places for a defensive fight, requiring no fine tweaking from the player.

In the next month a new video, and a better looking demo level is planned with new buildings and units, including complex wall, gate and tower systems, compound units like horsemen, chariots, or war elephans. As an essential AI feature, a new pathfinding error resolving system is coming, dealing with units being separated from their group, to avoid moments of bad game experience (what you can see in many commercial RTS games).

This is so cool! I look forward to seeing completion.

News #5

Hi,

after a long silence, news again. :slight_smile:

The reason for the delay: in November I started to work on another RTS project that requires a lot of time, using the engine’s default pathfinder and AI framework. Fortunately, it is a multiplayer game, so I could gain some knowledge and practice what can greatly help me to transform this project to be network compatible, which is today a very important feature of any game. Probably it is going to be not a quick job…

Beside making the movement system really rock solid in complex situations, creating a new environment is also in progress: new vegetation and new buildings are coming, and hopefully a new set of better unit models could appear. The next step is to create mounted units.

https://s26.postimg.org/ksjhby3ux/RTSRome000.png

https://s26.postimg.org/4itb91t6x/RTSRome003.png

https://s26.postimg.org/oepaola89/RTSRome006.png

News #6

Hi all,

the tests went fine with the new realistically sized modular walls and gates (according to Ancient Roman sources and ruins). The walls are 6m high, and only 2.5m thick, not too much place for a crowd… The gates are also narrower increasing time of passage, that inspires troops to use different gates where possible, even if the route is longer to finally decrease the overall movement time.

https://s26.postimg.org/p08c8ddl5/RTSRomeWalls00.png

https://s26.postimg.org/zbkp115ah/RTSRomeWalls01.png

Hi again,

I’m preparing a little demo with simple functionalities, like spawning/deleting groups of units, movement (open field, towers and walls), ungroup/regroup, change formation and weapon etc. in a level containing a little Roman town and some surrounding hills (500x500m area with tile resolution of 1000x1000), basically for performance tests:

https://s26.postimg.org/wajopit8p/PreDemo02.png

If you want to help me by providing some feedback, please PM me and you are going to receive a download link in the following weeks (I want to port it to 4.15 before). Because of its limitations, I want to keep it as a closed tech demo, I will provide an open version only for the next one having extended features (like damage units and buildings, attack/defend group behavior, open/close gates, cavalry units).

Thanks.

Multiplayer support - WIP

I decided to add multiplayer support to my RTS system, since I have gained some experience in this area thanks to another project.
Required only a week, still WIP, but the basics are working:

  • group and unit spawning,
  • server sided map data handling, pathfinding, and AI,
  • unit movement, animation, rotation,
  • bullet spawning,
  • a basic AI + human player system
    Fresh news coming soon… :slight_smile:

(unfortunately my old laptop can handle 2 instances of UE4 PIE windows very slowly)

https://s26.postimg.org/nqf60jxqh/multiplayer01.png

While those are important, for sure, if you are planning on multiplayer, the even more important core is a deterministic gameplay/simulation engine, to build the networking on top of.
If you’re building a game with 1500 units moving around (and can find a way to animate all of them without losing too much frame rate) then you need the network communication to not send the position of each object all the time, but instead just send player input commands per simulation tick, and make sure that all the machines resolve the simulation to the EXACT same state based on the EXACT same inputs.

All RTS-es with large unit counts use this form of networking. Unfortunately, Unreal by default doesn’t use a fixed timestep, and uses a physics engine that is not deterministic, so you can only use the built-in physics for eye candy; the “authoritative” position for each unit (which includes things like navigation and hit detection) must be simulated using a deterministic engine, and that typically should use fixed-point arithmetic rather than floating point for a variety of technical reasons. Floating point can be exact, but different CPUs may interpret the IEEE rules differently so it can’t be exact across AMD vs Intel vs ARM, and also not exact between compiler versions if you support Mac / Linux / Windows / whatever.

The best article on the things to look out for is 1500 Archers on a 28.8: Network Programming in Age of Empires and Beyond
It’s … probably 20 years ago? From an early Age of Empires game. The lessons it teaches are timeless, though – read it, study it, internalize it!

@****](https://forums.unrealengine.com/member.php?2525-) : thanks for the hints, I know the essence of these networking solutions, and read that article a while ago (and a couple of others), but I don’t want to write a whole game engine, nor a custom networking module, it would be far beyond my capabilities… By the way, there is an example of using a client-server approach in a recent RTS game, namely in Planetary Annihilation, here is a nice article (includes the same gamasutra link as your post as a great reference): The Tech of Planetary Annihilation: ChronoCam - ForrestTheWoods

My main focus is single player, and UE4 is perfect for it, and I think multiplayer can also work, hopefully one of the following two ways (probably only for a few hundred units):

  • First I implement a simple client-server system, which is quite simple, nearly as just passing movement vectors. Later I’m planning to do some smoothing by some additional data enabling some client side prediction. Soon we can see the results…
  • If it won’t work, there is a secondary plan to run the simulation both on server and clients, and regularly harmonize them, but I’m afraid of this way more, it could result in more difficulties and bad game experience when sync is really lost…

I have definitely many things to learn in this area, the most adventurous solution would be to implement both and compare them, in worst case I stay with single player mode. So any links, ideas, and advices are welcome :slight_smile:

Hi! How much bandwidth do you need for 100 units? Is the connection stable all the time ? I am asking because I am having issues with network stability from time to time.

I cut back some useless replicating data used only for testing, and will send you a screenshot with “stat net” in PM.

Moreover, I had an idea to decrease replication further, hopefully to approx. half, but it requires a new update loop for units on clients, what will be my next task… (I do not use ticking)

Very Nice, Congratulations, great work, pleasure to follow you, I like this kind of games,:wink: Hi

How come Unity fell out much earlier? And what were the reasons for choosing UE4 as an engine for a RTS game over the others?

I have never liked the licensing terms of Unity (the decision was made before Unity 5). Basically, I wanted to use C++ because strict memory and performance management is required by this game genre. Earlier it was developed in a C-like script language so porting was not too bad to UE4. Esenthel engine was also a possible choice, it uses C++ too, has nice rendering, simple, and fast, but its source license is a bit expensive comparing to UE4, beside having less features (Esenthel 1 was free, 2 requires a subscription). For me Cryengine’s main drawbacks were the asset pipeline (as a programmer I own no Maya or Photoshop) and Lua, what I felt a not very useful interim step.

I’m developing a game like dota2, but I can not find a solution for pathfinding between units. Can you give me some advice or how can I get your project for study?