Open RTS Plugin for Unreal Engine 4

It seems like there are still issues with this in basic UE4, see MoveTo task: How to move to player's location at any given location they are at - AI - Epic Developer Community Forums For now, I “fixed” it by raising the acceleration of the characters by a great deal, but I’m gonna review that in the future.

Thanks again for the warm words :slight_smile: It’s always nice to hear how many people seem to remember out little game :slight_smile:

Added #42 Resource Gathering](Resource Gathering · Issue #42 · npruehs/ue4-rts · GitHub) and #43 Construct Buildings](Construct Buildings · Issue #43 · npruehs/ue4-rts · GitHub) for this!

Added #44 Vehicle Support](Vehicle Support · Issue #44 · npruehs/ue4-rts · GitHub) and #45 Map Territories](Map Territories · Issue #45 · npruehs/ue4-rts · GitHub) for this!

I think those can be covered by Vehicle Support as well (see above). From a gameplay perspective, with vehicles in place, such as MG stand could be a (non-moving) vehicle that requires a “driver” to fire.

This is very gameplay-specific as well. I’d love to keep the plugin to the basics of RTS games, while being well-structured and extensible. For more specific gameplay, I’d refer to Gameplay Abilities, which have been developed by the Paragon team for similar features.

This is a UI task that’s specific to the game as well. Maybe I’m gonna add it to the sample game to illustrate how to do this.

Again, pretty game-specific, and there seem to be people out there who are much better in that than I am, just as you’ve shown :wink:

This one looks interesting, and shows me just like the other features above how different the RTS games are that both of us have in mind. Clearly, I’m thinking more of RTS games like WarCraft, StarCraft and Command & Conquer, which I’ve been playing for thousands of hours and I am most experienced at. However, I think a pretty basic yet flexible cover system could be added to the plugin, e.g. by providing CoverVolumes which can be dynamically spawned, if required. Added #46 Cover System](Cover System · Issue #46 · npruehs/ue4-rts · GitHub) for this.

I won’t take a closer look at improving replication or pathfinding until it becomes an issue. The thread you provide looks interesting, though. Will keep that one in mind!

In the meantime, I’ve implemented #4 Acquisition Radius](Acquisition Radius · Issue #4 · npruehs/ue4-rts · GitHub). Units will now automatically attack nearby enemies while idle, chase them, and return to their original position after leaving a certain radius.

One thing I considered is implementing client-side pawns for squads of infantry - you need only know where the invisible ‘squad’ entity is in terms of networking, and the pawns are handled entirely client-side, attempting to follow a loose formation. Weapons fire is handled by statistical modelling with misses, hits and casualties determined by the server, and rendered client side as-and-when. I believe this may be how Company of Heroes works under the hood; it’s light in terms of bandwidth and very robust, but the trick is in making unit behaviour moderately deterministic so that all players get a similar enough view of the game as it’s running.

Yes, that’s exactly how I imagined squad handling as well :slight_smile: Basically, we only need to replicate the location and rotation of the squad actor itself, as well as squad size and special equipment (e.g. rocket launcher against vehicles in Dawn of War or Company of Heroes). On client side, meshes are spawned matching the squad size and equipment, and projectiles are fired pseudo-randomly. Shouldn’t be too hard to do.

In the meantime, I’ve been trying to get my head around selection circles. I’m using decals here, just as we did in Unreal 3. However, the decals seem to have a short fade-in time (?), which by itself would even look awesome; however, this fade also causes them to flicker when moving. Any idea what might be causing this, and how deal with it?

I actually can’t see the problem in the video. How are the decals set up?

Sorry, YouTube had to process the video - and I’ve noticed that the quality is far better at youtube.com than here.

Anyway, I’ve created another thread for this. I guess it makes more sense to split out the question for a more specific discussion at How to properly project a moving texture onto a mesh? - Rendering - Epic Developer Community Forums

Hey everyone!

It’s been a little quiet around this one for the past few days, but that doesn’t mean there haven’t been any updates:

  • Health Bars
  • Player Names
  • Unit Portraits
  • Refactoring, Bugfixes, Replication Fixes

Next, I’m most probably gonna take a shot at the minimap :slight_smile:

Hi, npruehs, any chance you will submit this to the Unreal Marketplace for free, as an alternative to github? Thank you for the consideration.

Defintely: Yes! The main reason why I haven’t done so yet: I’m concerned with backwards-compatibility. I don’t want you having to rewire 100s of blueprints just because I decide to “put this function here instead of there”. After releasing this plugin on Marketplace, I’d definitely want to make sure to avoid that - but that slows me down significantly.

Is there any specific reason why you’re looking for a marketplace release? If you need anything, I’m sure we can work something out!

That’s great to hear. The reason I prefer the marketplace is simply because the end user doesn’t have to worry as much about accountability if anything turned out to be copyrighted or such, and it’s nice to have all of your addons in one place, especially if they ever receive an update.

@npruehs its looking good, just a question are you going to expose functions to blueprints like stats and on functions?

@OverRated_AU Sure, I’m exposing like … everything. Here’s a current list (in no particular order):

Blueprint Properites

  • AcquisitionRadius - Radius in which the actor will automatically select and attack targets, in cm.
  • ChaseRadius - Radius around the home location of the actor it won’t leave when automatically attacking targets, in cm.
  • Attacks - Attacks available for the actor. Different attacks might be used at different ranges, or against different types of targets.
  • Cooldown - Time before this attack can be used again, in seconds.
  • RemainingCooldown - Time before the next attack can be used, in seconds. This is shared between attacks.
  • Damage - Damage dealt by this attack. Negative values could mean healing, depending on the game.
  • DamageType - Type of the damage caused by this attack.
  • Range - Range of this attack, in cm.
  • ProjectileType - Type of the projectile to spawn. If not set, damage will be dealt instantly.
  • Portrait - Portrait of this character. Can be shown in the HUD.
  • InitialActors - Actors to spawn for each player in the game.
  • DefeatConditionActor - Optional type of actor that is required for a player to be alive. As soon as no actor of the specified type is alive, the player is defeated.
  • CurrentHealth - Current health of the actor.
  • MaximumHealth - Maximum health of the actor.
  • AlwaysShowHealthBars - Whether to always show all health bars. You may expose this in your own Options window: Some professional players might want this for perfect micro-management.
  • ShowHoverHealthBars - Whether to show health bars for hovered units.
  • ShowSelectionHealthBars - Whether to show health bars for selected units.
  • ShowHotkeyHealthBars - Whether to show health bars while the respective hotkey is pressed.
  • MinimapBackground - Brush for drawing the background of the current map.
  • OwnUnitsBrush - Brush for drawing own units on the minimap.
  • EnemyUnitsBrush - Brush for drawing enemy units on the minimap.
  • NeutralUnitsBrush - Brush for drawing neutral units on the minimap.
  • DrawBackground - Whether to draw the minimap background layer.
  • DrawUnitsWithTeamColors - Whether to draw unit dots on the minimap, with OwnUnitsBrush, EnemyUnitsBrush and NeutralUnitsBrush.
  • DrawViewFrustum - Whether to show the current camera frustum on the minimap.
  • CameraSpeed - Movement speed of the camera when moved with keys or mouse, in cm/sec.
  • CameraScrollThreshold - Distance from the screen border at which the mouse cursor causes the camera to move, in pixels.
  • ImpactThresholdSquared - Squared distance at which this projectile is detonated, in cm.

Blueprint Events

  • OnCooldownReady() - Event when the attack cooldown has expired.
  • OnDeselected() - Event when the character has been deselected.
  • OnHealthChanged(float OldHealth, float NewHealth) - Event when the current health of the character has changed.
  • OnKilled(AController* PreviousOwner) - Event when the character has been killed.
  • OnOwnerChanged(AController* NewOwner) - Event when the character is owned by a different player.
  • OnSelected() - Event when the character has been selected.
  • OnUsedAttack(const FRTSAttackData& Attack, AActor* Target, ARTSProjectile* Projectile) - Event when a character has used an attack.
  • OnPlayerDefeated(APlayerController* Player) - Event when a player has been defeated.
  • DrawHoveredActorEffect(AActor* HoveredActor) - Event for drawing an effect for the currently hovered actor.
  • DrawHealthBar(ARTSCharacter* Character, float CurrentHealth, float MaximumHealth, float HealthPercentage, float SuggestedHealthBarLeft, float SuggestedHealthBarTop, float SuggestedHealthBarWidth, float SuggestedHealthBarHeight) - Event for drawing the health bar for the specified character.
  • DrawSelectionFrame(float ScreenX, float ScreenY, float Width, float Height) - Event for drawing the selection frame because the mouse is being dragged.
  • OnDrawUnit(ARTSCharacter* Character, APlayerState* CharacterOwner, const FVector2D& MinimapPosition, APlayerState* LocalPlayer) - Event for custom drawing of units on the minimap (e.g. for drawing hero portraits for hero units).
  • OnActorOwnerChanged(AActor* Actor) - Event when this player is now owning the specified actor.
  • OnIssuedAttackOrder(AActor* Actor, AActor* Target) - Event when an actor has received an attack order.
  • OnIssuedMoveOrder(AActor* Actor, const FVector& TargetLocation) - Event when an actor has received a move order.
  • OnIssuedStopOrder(AActor* Actor) - Event when an actor has received a stop order.
  • OnMinimapClicked(const FPointerEvent& InMouseEvent, const FVector2D& MinimapPosition, const FVector& WorldPosition) - Event when the player has clicked a spot on the minimap.
  • OnSelectionChanged(const TArray<AActor*>& Selection) - Event when the set of selected actors of this player has changed.
  • OnProjectileDetonated(AActor* ProjectileTarget, float ProjectileDamage, TSubclassOf<class UDamageType> ProjectileDamageType, AController* ProjectileInstigator, AActor* ProjectileDamageCauser) - Event when this projectile hits its target.

Blueprint Functions

  • GetPlayerOwner() - Gets the player owning this character.
  • UseAttack(int AttackIndex, AActor* Target) - Uses the passed attack on the specified target and starts the cooldown timer.
  • FindTargetInAcquisitionRadius() - Makes the pawn look for a feasible target in its acquisition radius.
  • IssueAttackOrder(AActor* Target) - Makes the pawn attack the specified target.
  • IssueMoveOrder(const FVector& Location) - Makes the pawn move towards the specified location.
  • IssueStopOrder() - Makes the pawn stop all actions immediately.
  • GetHoveredActor() - Gets the actor currently hovered by this player.
  • GetSelectedActors() - Gets the list of units currently selected by this player.
  • SelectActors(TArray<AActor*> Actors) - Selects the specified actors.
  • SaveControlGroup(int Index) - Saves the current selection to the specified control group.
  • LoadControlGroup(int Index) - Restores the selection saved in the specified control group.
  • IsHealthBarHotkeyPressed() - Whether the hotkey for showing all health bars is currently pressed, or not.
  • TransferOwnership(AActor* Actor) - Sets this player as the owner of the specified actor.
  • FireAt(AActor* ProjectileTarget, float ProjectileDamage, TSubclassOf<class UDamageType> ProjectileDamageType, AController* ProjectileInstigator, AActor* ProjectileDamageCauser) - Locks on to the specified target, dealing damage on impact.

As you can see, there’s already quite a lot. You might use DefeatConditionActor to specify that a player should lose when his or her main building is destroyed - or all of their units. DrawHealthBar is nice for drawing your very own, custom health bars, without having to worry about finding the right position on screen. OnDrawUnit allows you to draw units in a custom way on the minimap, e.g. hero portraits for important units. With events like OnSelected or OnIssuedAttackOrder you could play confirmation voice lines. Or you could use TransferOwnership to rescue a unit when moving close enough.

Clearly, there’s more to come. In case you’re missing anything - feel free to tell me any time :slight_smile:

@npruehs thats a nice list, this was a detailed list of editable variables from SupCom2 they mite give you some ideas or to many haha :slight_smile: keep up the good work.

https://pastebin.com/tPutVgvL

I could put together a list of functions to, the way the moho engine worked was really great and quick to expand on.

@OverRated_AU - wow. That IS quite a list :smiley: As soon as I’m running out of things to do, I’ll take another close look at it :wink: Although my first quick glance tells me that I’ve already got most of it on my plate (except for specifics like naval units, maybe).

In the meantime, I’ve added a pretty modular minimap, with terrain layer, custom unit drawing (e.g. for hero units), view frustum, scrolling and minimap orders:

Also, I’ve added player teams, pretty much based on the good ol’ Unreal Tournament way of doing it. Now, I’m deep into building construction. I wanna make sure that it works like you expect it, and is still customizable enough to be useful for you (e.g. constructing buildings works fundamentally different in C&C than it does in WC3). Stay tuned!

Does not look like the video is available :frowning:

Sorry guys! @HeadClot and @franktech just notified me that the video was set to “private”. Sorry for the inconvenience. It was the first time I had to cut it using the YouTube Video Editor, and it seems that the result is private by default.

Another week gone already? Well, here you go :slight_smile:

I’d like to show you the next feature: Building Construction.

The video shows the following aspects, in order:

  1. Automatic Building (e.g. Protoss in StarCraft, Undead in WarCraft)
  2. Worker Attention, Multi-Building (e.g. Age of Empires, Humans in WarCraft)
  3. Entering Building Sites (e.g. Orcs in WarCraft)
  4. Consuming Workers (e.g. Zerg in StarCraft, Night Elves in WarCraft)

You can mix and match these aspects, e.g. enter building sites with multiple workers (and have them all consumed afterwards, or not), or speed up automatic building with multiple workers. As always, everything’s exposed to blueprints and works on both client and server.

Next up: Production (e.g. Training Units, Researching Technologies)

Looking mighty fine :smiley:

oh boy I love the flexibility, keep it up!

Hey everyone :slight_smile: It’s video time. Today: Production.

The video shows both the aspect of queueing up multiple items for production, and producing multiple items in parallel (e.g. barracks with reactor in StarCraft; not reflected by the sample game UI here, but you get the point). Note that this easily extends to upgrades, research, etc., which you can essentially design as actors to be spawned as well, just without physical representation.

I’m almost finished with resource gathering as well, which I wanted to be as flexible as building construction (see above). Stay tuned!

Thanks for sharing this man.
Just wonder if you have aplan to make this a master RTS package that can support squada based concepts like Company Of Heroes , Dawn of War . So instead of squeezing out units, we can use the pack to create per squad unit (1- n units per squad ).?