From 5104b336ca0b68e79488af24f7f6bc4d0150d1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0vec?= Date: Sat, 10 Aug 2024 19:53:06 +0200 Subject: [PATCH] Add multiplier dmg --- Assets/Scripts/Components/ProcessHitComponent.cs | 6 ++++-- Assets/Scripts/Components/RagdollComponent.cs | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Components/ProcessHitComponent.cs b/Assets/Scripts/Components/ProcessHitComponent.cs index d7c547eb..265ebbd4 100644 --- a/Assets/Scripts/Components/ProcessHitComponent.cs +++ b/Assets/Scripts/Components/ProcessHitComponent.cs @@ -15,9 +15,11 @@ public class ProcessHitComponent : MonoBehaviour if (ignored.Contains(source)) return; - Debug.Log("Got hit"); + var damage = args.damage.value; + var multiplier = args.hitMultiplier; + var finalDamage = damage * multiplier; - onTakeDamage.Invoke(args.damage.value); + onTakeDamage.Invoke((int)finalDamage); ignored.Add(args.source); } diff --git a/Assets/Scripts/Components/RagdollComponent.cs b/Assets/Scripts/Components/RagdollComponent.cs index 383f9e89..6829fb70 100644 --- a/Assets/Scripts/Components/RagdollComponent.cs +++ b/Assets/Scripts/Components/RagdollComponent.cs @@ -12,6 +12,8 @@ public class RagdollComponent : MonoBehaviour StartCoroutine(RagdollCoroutine()); } + // Needs to be coroutine, because if we modify all rigidbodies at the same time, + // unity play mode crashed in VR IEnumerator RagdollCoroutine() { var animators = GetComponentsInChildren();