From c9fc4fbbe205ff69fa20ded822b2214847b59726 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 18 Mar 2024 10:03:48 +0800 Subject: *misc --- _ActiveRagdoll/Actions/PlayerKnockback.cs | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 _ActiveRagdoll/Actions/PlayerKnockback.cs (limited to '_ActiveRagdoll/Actions/PlayerKnockback.cs') diff --git a/_ActiveRagdoll/Actions/PlayerKnockback.cs b/_ActiveRagdoll/Actions/PlayerKnockback.cs new file mode 100644 index 0000000..d4839bf --- /dev/null +++ b/_ActiveRagdoll/Actions/PlayerKnockback.cs @@ -0,0 +1,53 @@ +using UnityEngine; + +//Player PlayerKnockback ¶¯×÷-»÷ÍË +public class PlayerKnockback : MonoBehaviour +{ + private RigidbodyHolder allRigs;//14 + + private StandingDataHandler standing; + + private WeaponHandler weapons; + + private void Start() + { + allRigs = GetComponent(); + standing = GetComponent(); + weapons = GetComponent(); + } + + private void Update() + { + if (Input.GetKeyDown(KeyCode.K)) //kill + { + AddSeriousKnockback(); + } + } + + public void AddForce(Vector3 force, Rigidbody rig) + { + if (force.magnitude > 200f) + { + AddSeriousKnockback(); + force *= 0.1f; + } + for (int i = 0; i < allRigs.GetAllRigs().Length; i++) + { + float num = 1f; + if (rig == allRigs.GetAllRigs()[i]) + { + num *= 1f; + } + allRigs.GetAllRigs()[i].AddForce(force * num * 20f, ForceMode.Acceleration); + } + } + + private void AddSeriousKnockback() + { + GetComponent().Kill(); + } + + private void AddNormalKnockback() + { + } +} -- cgit v1.1-26-g67d0