From 929254005c7dc7437208715a6ae04b69292fe4f7 Mon Sep 17 00:00:00 2001 From: Neil Kollack Date: Thu, 14 Apr 2022 22:27:32 -0500 Subject: feat: player complete + player animation --- Assets/Scripts/Actors/Actor.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Assets/Scripts/Actors') 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 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; -- cgit v1.2.3-70-g09d2