private bool jumping;
private bool sliding;
private bool wallHolding;
private bool stopSliding;
// Components
private PlayerPhysics playerPhysics;
private Animator animator;
// private GameManager manager;
void Start () {
playerPhysics = GetComponent<PlayerPhysics>();
animator = GetComponent<Animator>();
//manager = Camera.main.GetComponent<GameManager>();
animator.SetLayerWeight(1,1);
}
void Update () {
// Reset acceleration upon collision
if (playerPhysics.movementStopped) {
targetSpeed = 0;
currentSpeed = 0;
}
//player slash
if (Input.GetButtonDown("slashing"))
{
animator.SetTrigger("slash2");
}
// If player is touching the ground
if (playerPhysics.grounded) {
amountToMove.y = 0;
if (wallHolding) {
wallHolding = false;
animator.SetBool("Wall Hold", false);
}
// Jump logic
if (jumping) {
jumping = false;
animator.SetBool("Jumping",false);
}
// Slide logic
if (sliding) {
if (Mathf.Abs(currentSpeed) < .25f || stopSliding) {
stopSliding = false;
sliding = false;
animator.SetBool("Sliding",false);
playerPhysics.ResetCollider();
}
}
// Slide Input
if (Input.GetButtonDown("seret")) {
if (Mathf.Abs(currentSpeed) > initiateSlideThreshold) {
sliding = true;
animator.SetBool("Sliding",true);
targetSpeed = 0;
playerPhysics.SetCollider(new Vector3(10.3f,1.5f,3), new Vector3(.35f,.75f,0));
}
}
}
else {
if (!wallHolding) {
if (playerPhysics.canWallHold) {
wallHolding = true;
animator.SetBool("Wall Hold", true);
}
}
}
// Jump Input
if (Input.GetButtonDown("Jump")) {
if (sliding) {
stopSliding = true;
}
else if (playerPhysics.grounded || wallHolding) {
amountToMove.y = jumpHeight;
jumping = true;
animator.SetBool("Jumping",true);
if (wallHolding) {
wallHolding = false;
animator.SetBool("Wall Hold", false);
}
}
}