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

@ -32038,13 +32038,17 @@ PrefabInstance:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: -1 value: -1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8574288191223281125, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3}
propertyPath: m_LocalScale.y
value: 3.9620514
objectReference: {fileID: 0}
- target: {fileID: 8574288191223281125, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3} - target: {fileID: 8574288191223281125, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -22.510845 value: -22.510845
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8574288191223281125, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3} - target: {fileID: 8574288191223281125, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: -39.089523 value: -38.8252
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8574288191223281125, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3} - target: {fileID: 8574288191223281125, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z

View File

@ -19,15 +19,12 @@ public class PlayerBehavior : MonoBehaviour
[Header("Clarinet:")] [Header("Clarinet:")]
bool unlockedClarinet; 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; private float currentDashTime;
public bool isDash = false; public bool isDash = false;
public float bonk = 2f; public float bonk = 2f;
private Vector2 saveVelocity; private Vector2 saveVelocity;
public bool isInWater = false; public bool isInWater = false;
public float dashForce = 1.5f;
[Header("Grappling:")] [Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun; [SerializeField] public Tutorial_GrapplingGun grapplingGun;
@ -100,21 +97,20 @@ public class PlayerBehavior : MonoBehaviour
if (playerInput.actions["ClarinetDive"].WasPressedThisFrame()) if (playerInput.actions["ClarinetDive"].WasPressedThisFrame())
{ {
isDash = true; isDash = true;
currentDashTime = 0.0f;
playerInput.DeactivateInput(); playerInput.DeactivateInput();
} }
if (!playerController.IsGrounded() && (currentDashTime < maxDashTime) && isDash) if (!playerController.IsGrounded() && isDash)
{ {
if (forward == 1) if (forward == 1)
{ {
moveDirection = new Vector3(1f, -1f, 0f) * dashDistance; Vector2 rightDash = new Vector2(1f, -1f) * dashForce;
_rb.AddForce(rightDash, ForceMode2D.Impulse);
} }
else 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 else
{ {
@ -286,6 +282,7 @@ public class PlayerBehavior : MonoBehaviour
else if (col.tag == "water") else if (col.tag == "water")
{ {
isInWater = false; 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 //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)); RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
} }
/*else if (playerBehavior.isInWater) else if (playerBehavior.isInWater)
{ {
SetGravityScale(0); SetGravityScale(0);
}*/ }
else else
{ {
//Default gravity if standing on a platform or moving upwards //Default gravity if standing on a platform or moving upwards