From 9dea78edb7f47ed7fb1b1f53e4d2e727ac10ffa7 Mon Sep 17 00:00:00 2001 From: Sveske Juice Date: Sat, 3 Feb 2024 06:03:38 -0800 Subject: [PATCH] natural whip swing --- Assets/Scripts/Player/PlayerMovement.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index d9226cc..4758c3d 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -57,12 +57,12 @@ public class PlayerMovement : MonoBehaviour { if (whipAttack.IsBeingWhipped) { - float sign = movement.x > 0 ? 1 : -1; - if (movement.x == 0) - sign = 0; + //float sign = Vector2.Dot((whipAttack.joint.position - whipAttack.otherPlayerAttack.joint.position).normalized, movement.normalized); + Vector2 ropeDir = whipAttack.otherPlayerAttack.joint.position - whipAttack.joint.position; Vector2 tangent = new Vector2(-ropeDir.y, ropeDir.x).normalized; - rb.AddForce(tangent * whipMoveSpeed * sign); + + rb.AddForce(Vector2.Dot(movement, tangent) * tangent * whipMoveSpeed); rb.velocity = Vector2.ClampMagnitude(rb.velocity, maxWhipMoveSpeed); } else if (whipAttack.IsWhippingOtherPlayer)