diff --git a/Assets/Scripts/PlayerScripts/KickController.cs b/Assets/Scripts/PlayerScripts/KickController.cs index 9c5d412..e3d90e1 100644 --- a/Assets/Scripts/PlayerScripts/KickController.cs +++ b/Assets/Scripts/PlayerScripts/KickController.cs @@ -12,12 +12,12 @@ public class KickController : NetworkBehaviour //slightly bad practice, when merging find a better work around private bool isDiveKicking = false; private CharacterController characterController; - + public PlayerMovement pMove; public PlayerStats pStats; void Start(){ pStats = GetComponent(); - + pMove = GetComponent(); characterController = this.gameObject.GetComponent(); leg = transform.GetChild(0).gameObject; leg.SetActive(false); @@ -31,7 +31,7 @@ public class KickController : NetworkBehaviour //Note: when we merge this into PlayerMovement, we may want to change isgrounded to our //custom is grounded //If F is pressed or gamepad right trigger is pulled - if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false && characterController.isGrounded == false) + if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false && pMove.isGrounded == false) { Debug.Log("dive"); // if kicking in air, kick until grounded (maybe add some foward momentum if needeD) @@ -40,12 +40,13 @@ public class KickController : NetworkBehaviour leg.SetActive(true); } //otherwise do ground kick for .3 seconds - else if (( Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){ + else if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){ StartCoroutine(Kicking(.3f)); } //once dive kick touches ground, set back to normal state - if(characterController.isGrounded == true && isDiveKicking == true){ + if (pMove.isGrounded == true && isDiveKicking == true) + { isDiveKicking = false; isKicking = false; leg.SetActive(false); @@ -62,7 +63,7 @@ public class KickController : NetworkBehaviour } - private void OnCollisionEnter(Collision collision) + private void OnCollisionEnter(Collision collision) { //if (!IsLocalPlayer) { return; } Collider myCollider = collision.contacts[0].thisCollider; @@ -75,7 +76,7 @@ public class KickController : NetworkBehaviour collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse); } if (collision.transform.CompareTag("destroyable") && myCollider == leg.GetComponent()){ - collision.rigidbody.gameObject.GetComponent().damage(pStats.KickPow); + collision.transform.gameObject.GetComponent().damage(pStats.KickPow); } } diff --git a/Assets/Scripts/PlayerScripts/PlayerMovement.cs b/Assets/Scripts/PlayerScripts/PlayerMovement.cs index 74bb5ae..21ee741 100644 --- a/Assets/Scripts/PlayerScripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/PlayerMovement.cs @@ -89,6 +89,9 @@ public class PlayerMovement : NetworkBehaviour //Blink private Blink blink; + //Animation controller + Animator animator; + void Awake() { //Initialize Player Components @@ -97,6 +100,7 @@ public class PlayerMovement : NetworkBehaviour capCol = GetComponent(); // Capsule Collider capCol.enabled = false; parentObj = transform.parent.gameObject; + animator = GetComponent(); //Initialize Scripts pStats = GetComponent(); // PlayerStats @@ -196,6 +200,20 @@ public class PlayerMovement : NetworkBehaviour //Slide Function Slide(); + //move animation + //if vel from input is greater than 0, start sprinting animation + if (PlayerSpeed() > 0.1) + { + //Debug.Log(driftVel.magnitude); + + if(animator != null) animator.SetBool("isRunning", true); + } + //if low enough movement from player (this will be still at this value) stop animation + else if (driftVel.magnitude < .510f) + { + if(animator != null) animator.SetBool("isRunning", false); + } + //Move Player moveController.Move(driftVel + (moveY * Time.deltaTime)); }