Merge remote-tracking branch 'origin/master'

This commit is contained in:
Sam 2023-05-04 21:17:47 -07:00
commit a3552eac81

View File

@ -23,11 +23,13 @@ public class PlayerBehavior : MonoBehaviour
public float bonk = 2f; public float bonk = 2f;
private Vector2 saveVelocity; private Vector2 saveVelocity;
public bool isInWater = false; public bool isInWater = false;
//dont know if gravity matters
public float dashForce = 1.2f; public float dashForce = 1.2f;
private float dashTime = 1.0f; private float dashTime = 1.0f;
private float dashInc = 0.1f; private float dashInc = 0.1f;
private float currentDash = 0.0f; private float currentDash = 0.0f;
Vector2 dashVec; Vector2 dashVec;
private bool lowSpeed = false;
[Header("Grappling:")] [Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun; [SerializeField] public Tutorial_GrapplingGun grapplingGun;
@ -126,6 +128,11 @@ public class PlayerBehavior : MonoBehaviour
dashVec = Vector2.zero; dashVec = Vector2.zero;
playerInput.ActivateInput(); playerInput.ActivateInput();
} }
else
{
currentDash = 0.0f;
dashVec = Vector2.zero;
}
} }
} }
@ -231,21 +238,27 @@ public class PlayerBehavior : MonoBehaviour
void Bounce() void Bounce()
{ {
if(isDash) Vector2 reflect;
if(lowSpeed)
{ {
Vector2 reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * bonk); reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * 0.75f);
_rb.AddForce(reflect, ForceMode2D.Impulse);
reflect = Vector2.zero;
} }
else
{
reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * bonk);
}
//reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * bonk);
_rb.AddForce(reflect, ForceMode2D.Impulse);
reflect = Vector2.zero;
isDash = false;
} }
void Water() void Water()
{ {
if(Mathf.Abs(_rb.velocity.y) < 2f) if (Mathf.Abs(_rb.velocity.y) < 2f)
{ {
lowSpeed = true;
saveVelocity = Vector2.zero; saveVelocity = Vector2.zero;
isInWater = true;
} }
else else
{ {
@ -276,6 +289,7 @@ public class PlayerBehavior : MonoBehaviour
} }
else if (col.tag == "water") else if (col.tag == "water")
{ {
isInWater = true;
Water(); Water();
} }
} }
@ -294,6 +308,8 @@ public class PlayerBehavior : MonoBehaviour
else if (col.tag == "water") else if (col.tag == "water")
{ {
isInWater = false; isInWater = false;
isDash = false;
playerInput.ActivateInput();
saveVelocity = Vector2.zero; saveVelocity = Vector2.zero;
} }
} }
@ -342,6 +358,7 @@ public class PlayerBehavior : MonoBehaviour
audioSource.clip = deathSound; audioSource.clip = deathSound;
audioSource.loop = false; audioSource.loop = false;
audioSource.Play(); audioSource.Play();
playerInput.ActivateInput();
// animate // animate
animator.Play("Die"); animator.Play("Die");