Index: binaries/data/mods/public/simulation/components/ResourceGatherer.js =================================================================== --- binaries/data/mods/public/simulation/components/ResourceGatherer.js +++ binaries/data/mods/public/simulation/components/ResourceGatherer.js @@ -98,6 +98,11 @@ return undefined; }; +ResourceGatherer.prototype.SetLastCarriedType = function(lastCarriedType) +{ + this.lastCarriedType = lastCarriedType; +} + // Since this code is very performancecritical and applying technologies quite slow, cache it. ResourceGatherer.prototype.RecalculateGatherRatesAndCapacities = function() { Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -3023,6 +3023,7 @@ "leave": function() { this.StopTimer(); this.ResetAnimation(); + this.SetDefaultAnimationVariant(); var cmpResistance = Engine.QueryInterface(this.entity, IID_Resistance); cmpResistance.SetInvulnerability(false); }, @@ -4208,6 +4209,16 @@ */ UnitAI.prototype.SetDefaultAnimationVariant = function() { + if (this.formationController) + { + let cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); + if (cmpFormation) + { + this.SetAnimationVariant(cmpFormation.GetFormationAnimation(this.entity)); + return; + } + } + let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); if (!cmpResourceGatherer) { Index: binaries/data/mods/public/simulation/helpers/Transform.js =================================================================== --- binaries/data/mods/public/simulation/helpers/Transform.js +++ binaries/data/mods/public/simulation/helpers/Transform.js @@ -88,6 +88,7 @@ { let carriedResources = cmpResGatherer.GetCarryingStatus(); cmpNewResGatherer.GiveResources(carriedResources); + cmpNewResGatherer.SetLastCarriedType(cmpResGatherer.GetLastCarriedType()); }