summaryrefslogtreecommitdiff
path: root/GameCode/TracerTarget.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-10-27 11:05:14 +0800
committerchai <215380520@qq.com>2023-10-27 11:05:14 +0800
commit766cdff5ffa72b65d7f106658d1603f47739b2ba (patch)
tree34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/TracerTarget.cs
+ init
Diffstat (limited to 'GameCode/TracerTarget.cs')
-rw-r--r--GameCode/TracerTarget.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/GameCode/TracerTarget.cs b/GameCode/TracerTarget.cs
new file mode 100644
index 0000000..19b6b67
--- /dev/null
+++ b/GameCode/TracerTarget.cs
@@ -0,0 +1,65 @@
+using UnityEngine;
+
+public class TracerTarget : MonoBehaviour
+{
+ private MoveTransform move;
+
+ public bool hasPos;
+
+ public float drag;
+
+ public float spring;
+
+ public AnimationCurve curve;
+
+ public float cosScale = 1f;
+
+ public float cosAmount;
+
+ private float random;
+
+ private float c;
+
+ private bool done;
+
+ private Vector3 tPos;
+
+ private Vector3 upDir;
+
+ private MoveTransform mTrans;
+
+ private void Start()
+ {
+ move = GetComponent<MoveTransform>();
+ random = Random.Range(0f, 1000f);
+ SetPos(base.transform.forward * 100f, base.transform.up, null);
+ }
+
+ private void Update()
+ {
+ float num = 1f;
+ if ((bool)mTrans)
+ {
+ num += mTrans.velocity.magnitude * 0.1f;
+ }
+ if ((bool)mTrans && !done)
+ {
+ tPos += base.transform.forward + base.transform.forward * 10f;
+ }
+ c += TimeHandler.deltaTime;
+ if (hasPos)
+ {
+ move.velocity += cosAmount * Mathf.Cos((Time.time + random) * cosScale) * upDir * CappedDeltaTime.time / num;
+ move.velocity += (tPos - base.transform.position).normalized * spring * CappedDeltaTime.time * curve.Evaluate(c) * num;
+ move.velocity -= move.velocity * CappedDeltaTime.time * drag * curve.Evaluate(c);
+ }
+ }
+
+ public void SetPos(Vector3 targetPos, Vector3 up, MoveTransform move)
+ {
+ mTrans = move;
+ hasPos = true;
+ tPos = targetPos;
+ upDir = up;
+ }
+}