aboutsummaryrefslogtreecommitdiffstats
path: root/Assets/Scripts/Actors/Actor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Actors/Actor.cs')
-rw-r--r--Assets/Scripts/Actors/Actor.cs16
1 files changed, 10 insertions, 6 deletions
diff --git a/Assets/Scripts/Actors/Actor.cs b/Assets/Scripts/Actors/Actor.cs
index 2e98974..55aed29 100644
--- a/Assets/Scripts/Actors/Actor.cs
+++ b/Assets/Scripts/Actors/Actor.cs
@@ -21,14 +21,14 @@ namespace MontanaJohns.Actors
protected Animator _animator;
protected Transform _transform;
- public Stats stats;
+ protected Stats stats;
protected Active activeItem;
protected bool isGrappling;
protected Vector2? grapplePoint = null;
protected LayerMask groundLayers;
Collection<Item> items;
- public int health;
+ protected int health;
protected int jumpCount;
protected Vector2 acceleration;
@@ -81,8 +81,13 @@ namespace MontanaJohns.Actors
public virtual void Jump()
{
- if (jumpCount++ <= stats.maxJumps)
+ if(Physics2D.OverlapCircle(groundCheckPoint.position, 0.2f, groundLayers))
{
+ jumpCount = stats.maxJumps;
+ }
+ if (jumpCount > 0)
+ {
+ jumpCount--;
_rigidBody.AddForce(Vector2.up * stats.jumpForce);
_animator.SetTrigger("jump");
_animator.SetBool("airborn", true);
@@ -127,12 +132,11 @@ namespace MontanaJohns.Actors
{
_animator.SetBool("airborn", true);
- while (_rigidBody.velocity.y > 0 || !Physics2D.OverlapCircle(groundCheckPoint.position, 0.2f, groundLayers))
+ while (!Physics2D.OverlapCircle(groundCheckPoint.position, 0.2f, groundLayers))
{
- yield return new WaitForFixedUpdate();
+ yield return new WaitForEndOfFrame();
}
- jumpCount = 0;
_animator.SetBool("airborn", false);
yield break;