fgm24/Assets/Scripts/Player/RopeWhipAttack.cs

41 lines
990 B
C#
Raw Normal View History

2024-02-03 14:07:03 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
2024-02-03 15:21:45 +01:00
using System.Linq;
2024-02-03 14:07:03 +01:00
public class RopeWhipAttack : MonoBehaviour
{
2024-02-03 16:21:32 +01:00
[SerializeField] PlayerInput playerInput;
2024-02-03 14:07:03 +01:00
public RopeWhipAttack otherPlayerAttack;
public PlayerMovement playerMovement;
public RopeJoint joint;
public bool IsWhippingOtherPlayer => joint.locked;
public bool IsBeingWhipped => otherPlayerAttack.joint.locked;
public float initialDrag;
private void Awake()
{
initialDrag = joint.body.drag;
}
private void Update()
{
// Other player is whip attacking
if (otherPlayerAttack.joint.locked) return;
2024-02-03 16:21:32 +01:00
if (playerInput.whipAttack)
2024-02-03 14:07:03 +01:00
{
joint.locked = true;
otherPlayerAttack.joint.body.drag = 0f;
}
else
{
joint.locked = false;
otherPlayerAttack.joint.body.drag = otherPlayerAttack.initialDrag;
}
}
}