From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/IKArmMove.cs | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 GameCode/IKArmMove.cs (limited to 'GameCode/IKArmMove.cs') diff --git a/GameCode/IKArmMove.cs b/GameCode/IKArmMove.cs new file mode 100644 index 0000000..ee14990 --- /dev/null +++ b/GameCode/IKArmMove.cs @@ -0,0 +1,56 @@ +using UnityEngine; + +public class IKArmMove : MonoBehaviour +{ + private CharacterData data; + + private PlayerVelocity rig; + + public Transform target; + + private Vector3 startPos; + + private Holding holding; + + private bool isActive; + + private Vector3 velolcity; + + private float sinceRaise = 10f; + + private void Start() + { + data = GetComponentInParent(); + rig = GetComponentInParent(); + startPos = target.localPosition; + holding = GetComponentInParent(); + } + + private void Update() + { + isActive = false; + sinceRaise += TimeHandler.deltaTime; + if ((bool)holding.holdable && (bool)holding.holdable.rig && holding.holdable.rig.transform.position.x > rig.transform.position.x == base.transform.position.x > rig.transform.position.x) + { + target.position = holding.holdable.rig.transform.position; + velolcity = Vector3.zero; + isActive = true; + return; + } + Vector3 vector = base.transform.parent.TransformPoint(startPos) + ((sinceRaise < 0.3f) ? Vector3.up : Vector3.zero); + Vector3 vector2 = rig.velocity; + vector2.x *= 0.3f; + velolcity = FRILerp.Lerp(velolcity, (vector - target.position) * 15f, 15f); + target.position += velolcity * TimeHandler.deltaTime; + target.position += vector2 * -0.3f * TimeHandler.deltaTime; + } + + public void RaiseHands() + { + if (!isActive) + { + sinceRaise = 0f; + velolcity += Vector3.up * 20f; + } + } +} -- cgit v1.1-26-g67d0