update dash implementation
This commit is contained in:
@@ -19,15 +19,12 @@ public class PlayerBehavior : MonoBehaviour
|
||||
|
||||
[Header("Clarinet:")]
|
||||
bool unlockedClarinet;
|
||||
[SerializeField] private float maxDashTime = 2.5f;
|
||||
[SerializeField] private float dashStopSpeed = 0.1f;
|
||||
public Vector3 moveDirection;
|
||||
public float dashDistance = 0.1f;
|
||||
private float currentDashTime;
|
||||
public bool isDash = false;
|
||||
public float bonk = 2f;
|
||||
private Vector2 saveVelocity;
|
||||
public bool isInWater = false;
|
||||
public float dashForce = 1.5f;
|
||||
|
||||
[Header("Grappling:")]
|
||||
[SerializeField] public Tutorial_GrapplingGun grapplingGun;
|
||||
@@ -100,21 +97,20 @@ public class PlayerBehavior : MonoBehaviour
|
||||
if (playerInput.actions["ClarinetDive"].WasPressedThisFrame())
|
||||
{
|
||||
isDash = true;
|
||||
currentDashTime = 0.0f;
|
||||
playerInput.DeactivateInput();
|
||||
}
|
||||
if (!playerController.IsGrounded() && (currentDashTime < maxDashTime) && isDash)
|
||||
if (!playerController.IsGrounded() && isDash)
|
||||
{
|
||||
if (forward == 1)
|
||||
{
|
||||
moveDirection = new Vector3(1f, -1f, 0f) * dashDistance;
|
||||
Vector2 rightDash = new Vector2(1f, -1f) * dashForce;
|
||||
_rb.AddForce(rightDash, ForceMode2D.Impulse);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveDirection = new Vector3(-1f, -1f, 0f) * dashDistance;
|
||||
Vector2 leftDash = new Vector2(-1f, -1f) * dashForce;
|
||||
_rb.AddForce(leftDash, ForceMode2D.Impulse);
|
||||
}
|
||||
transform.position = transform.position + moveDirection;
|
||||
currentDashTime += dashStopSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -286,6 +282,7 @@ public class PlayerBehavior : MonoBehaviour
|
||||
else if (col.tag == "water")
|
||||
{
|
||||
isInWater = false;
|
||||
saveVelocity = Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user