diff --git a/Assets/Scripts/SS3D/Systems/Entities/Humanoid/HumanoidAnimatorController.cs b/Assets/Scripts/SS3D/Systems/Entities/Humanoid/HumanoidAnimatorController.cs index f4c4a7751..4ad05b714 100644 --- a/Assets/Scripts/SS3D/Systems/Entities/Humanoid/HumanoidAnimatorController.cs +++ b/Assets/Scripts/SS3D/Systems/Entities/Humanoid/HumanoidAnimatorController.cs @@ -27,40 +27,6 @@ protected override void OnDestroyed() UnsubscribeFromEvents(); } - private void SubscribeToEvents() - { - _movementController.OnSpeedChangeEvent += UpdateMovement; - InstanceFinder.TimeManager.OnTick += HandleNetworkTick; - } - - private void HandleGunAim(object sender, bool isAiming) - { - if (isAiming) - { - // Get the index of the layer named "UpperBody" - _animator.SetBool("Aim", true); - } - else - { - _animator.SetBool("Aim", false); - } - } - - private void UnsubscribeFromEvents() - { - _movementController.OnSpeedChangeEvent -= UpdateMovement; - } - - private void UpdateMovement(float speed) - { - bool isMoving = speed != 0; - float currentSpeed = _animator.GetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed); - float newLerpModifier = isMoving ? _lerpMultiplier : (_lerpMultiplier * 3); - speed = Mathf.Lerp(currentSpeed, speed, Time.deltaTime * newLerpModifier); - - _animator.SetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed, speed); - } - public void Sit(bool sitState) { _animator.SetBool("Sit", sitState); @@ -129,5 +95,39 @@ private void HandleNetworkTick() { _animator.SetFloat("AngleAimMove", (_movementController.InputAimAngle / 360f) + 0.5f); } + + private void SubscribeToEvents() + { + _movementController.OnSpeedChangeEvent += UpdateMovement; + InstanceFinder.TimeManager.OnTick += HandleNetworkTick; + } + + private void HandleGunAim(object sender, bool isAiming) + { + if (isAiming) + { + // Get the index of the layer named "UpperBody" + _animator.SetBool("Aim", true); + } + else + { + _animator.SetBool("Aim", false); + } + } + + private void UnsubscribeFromEvents() + { + _movementController.OnSpeedChangeEvent -= UpdateMovement; + } + + private void UpdateMovement(float speed) + { + bool isMoving = speed != 0; + float currentSpeed = _animator.GetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed); + float newLerpModifier = isMoving ? _lerpMultiplier : (_lerpMultiplier * 3); + speed = Mathf.Lerp(currentSpeed, speed, Time.deltaTime * newLerpModifier); + + _animator.SetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed, speed); + } } } diff --git a/Assets/Scripts/SS3D/Systems/Inventory/Containers/Hand.cs b/Assets/Scripts/SS3D/Systems/Inventory/Containers/Hand.cs index f44146295..0f09f0b44 100644 --- a/Assets/Scripts/SS3D/Systems/Inventory/Containers/Hand.cs +++ b/Assets/Scripts/SS3D/Systems/Inventory/Containers/Hand.cs @@ -142,6 +142,7 @@ public void Awake() public override void CreateSourceInteractions(IInteractionTarget[] targets, List entries) { + // todo : hands should not handle sit interactions, ass should, but the interaction controller needs some changes to handle interaction sources other than hands base.CreateSourceInteractions(targets, entries); IInteractionTarget target = targets.FirstOrDefault(x => x?.GameObject.GetComponent());