update dash implementation

This commit is contained in:
allylikesfrogs
2023-05-04 17:11:09 -07:00
parent 368fbcb634
commit ce71c20acb
3 changed files with 14 additions and 13 deletions

View File

@@ -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;
}
}

View File

@@ -310,10 +310,10 @@ public class PlayerMovement : MonoBehaviour
//Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
}
/*else if (playerBehavior.isInWater)
else if (playerBehavior.isInWater)
{
SetGravityScale(0);
}*/
}
else
{
//Default gravity if standing on a platform or moving upwards