using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using System.Linq; public class RopeWhipAttack : MonoBehaviour { public RopeWhipAttack otherPlayerAttack; public PlayerMovement playerMovement; public RopeJoint joint; Gamepad controller; public bool IsWhippingOtherPlayer => joint.locked; public bool IsBeingWhipped => otherPlayerAttack.joint.locked; public float initialDrag; private void Awake() { initialDrag = joint.body.drag; controller = Gamepad.all.ElementAtOrDefault(playerMovement.player); } private void Update() { // Other player is whip attacking if (otherPlayerAttack.joint.locked) return; if (controller == null) return; if (controller.rightShoulder.IsPressed()) { joint.locked = true; otherPlayerAttack.joint.body.drag = 0f; } else { joint.locked = false; otherPlayerAttack.joint.body.drag = otherPlayerAttack.initialDrag; } } }