From 19c9e3e4f9a81d910c0b75cc00282b74926a9b69 Mon Sep 17 00:00:00 2001 From: Clyybber Date: Fri, 5 Jun 2020 13:00:32 +0200 Subject: [PATCH] Make attack animation follow the character (#1071) * Fix #971 * Make atacker parent of the animation instead --- .../Weapons/Melee/MeleeWeaponArcAnimationComponent.cs | 7 +++++-- .../GameObjects/EntitySystems/MeleeWeaponSystem.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs b/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs index f2e2964c2b..ff166c8800 100644 --- a/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs +++ b/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs @@ -2,6 +2,7 @@ using Content.Shared.GameObjects.Components.Weapons.Melee; using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Maths; namespace Content.Client.GameObjects.Components.Weapons.Melee @@ -24,11 +25,12 @@ namespace Content.Client.GameObjects.Components.Weapons.Melee _sprite = Owner.GetComponent(); } - public void SetData(MeleeWeaponAnimationPrototype prototype, Angle baseAngle) + public void SetData(MeleeWeaponAnimationPrototype prototype, Angle baseAngle, IEntity attacker) { _meleeWeaponAnimation = prototype; _sprite.AddLayer(new RSI.StateId(prototype.State)); _baseAngle = baseAngle; + Owner.Transform.AttachParent(attacker); } internal void Update(float frameTime) @@ -48,11 +50,12 @@ namespace Content.Client.GameObjects.Components.Weapons.Melee { case WeaponArcType.Slash: var angle = Angle.FromDegrees(_meleeWeaponAnimation.Width)/2; - Owner.Transform.LocalRotation = + Owner.Transform.WorldRotation = _baseAngle + Angle.Lerp(-angle, angle, (float) (_timer / _meleeWeaponAnimation.Length.TotalSeconds)); break; case WeaponArcType.Poke: + Owner.Transform.WorldRotation = _baseAngle; _sprite.Offset += (_meleeWeaponAnimation.Speed * frameTime, 0); break; } diff --git a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs index 9691ecafb3..17dcde3023 100644 --- a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -54,7 +54,7 @@ namespace Content.Client.GameObjects.EntitySystems entity.Transform.LocalRotation = msg.Angle; var weaponArcAnimation = entity.GetComponent(); - weaponArcAnimation.SetData(weaponArc, msg.Angle); + weaponArcAnimation.SetData(weaponArc, msg.Angle, attacker); foreach (var uid in msg.Hits)