using UnityEngine; public class RopeTestLogic : MonoBehaviour { public GameObject fishingRod; public GameObject bait; public GameObject baitStartPos; public GameObject rodEndPos; public UltimateRope rope; public float throwStrength = 10f; public float ropeLengthMargin = 3f; private bool isThrown; private void Start() { rope.Regenerate(); rope.GetComponent().UpdateNodes(rope); } private void Update() { if (Input.GetKeyDown(KeyCode.T)) { ThrowBait(); } if (Input.GetKeyDown(KeyCode.R)) { ResetBait(); } if (Input.GetKeyDown(KeyCode.Z)) { rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement, -0.1f); } else if (Input.GetKeyDown(KeyCode.X)) { rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement, 0.1f); } if (isThrown) { UpdateRope(); } } public void UpdateRope() { float num = Vector3.Distance(rodEndPos.transform.position, bait.transform.position); if (rope.m_fCurrentExtension < num + ropeLengthMargin - rope.RopeNodes[0].fLength) { rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement, num + ropeLengthMargin - rope.RopeNodes[0].fLength - rope.m_fCurrentExtension); } } public void ThrowBait() { bait.transform.localRotation = Quaternion.Euler(0f, 0f, 0f); Vector3 forward = base.transform.forward; bait.GetComponent().isKinematic = false; bait.GetComponent().AddForce(forward * throwStrength); isThrown = true; } public void ResetBait() { bait.transform.position = baitStartPos.transform.position; bait.GetComponent().isKinematic = true; bait.GetComponent().velocity = Vector3.zero; bait.GetComponent().angularVelocity = Vector3.zero; rope.ExtendRope(UltimateRope.ERopeExtensionMode.LinearExtensionIncrement, 0f - rope.m_fCurrentExtension); isThrown = false; } }