public void setAnimatorParameters() { // SET animator velocity floats animator.SetFloat(animatorHashCodes.velocityX, localPhysicsEngine.velocity.x); animator.SetFloat(animatorHashCodes.velocityY, localPhysicsEngine.velocity.y); // SET animator vertical collision bools LocalCollisionManager.CollisionData collisionData = localPhysicsEngine.localCollisionManager.collisionData; if (collisionData.bottomCollision) { animator.SetBool(animatorHashCodes.collidedDown, true); } else if (collisionData.topCollision) { animator.SetBool(animatorHashCodes.collidedUp, true); } else { animator.SetBool(animatorHashCodes.collidedUp, false); animator.SetBool(animatorHashCodes.collidedDown, false); } // SET player sprite direction (Decide to mirror the sprite) if (moveRight && !moveLeft) { spriteScale.x = Mathf.Abs(spriteScale.x); } else if (!moveRight && moveLeft) { spriteScale.x = -Mathf.Abs(spriteScale.x); } this.gameObject.transform.localScale = spriteScale; }
public void updateAnimatorParameters() { // SET animator velocity floats animator.SetFloat(animatorHashCodes.velocityX, localPhysicsEngine.velocity.x); animator.SetFloat(animatorHashCodes.velocityY, localPhysicsEngine.velocity.y); // SET animator vertical collision bools LocalCollisionManager.CollisionData collisionData = localPhysicsEngine.localCollisionManager.collisionData; if (collisionData.bottomCollision) { animator.SetBool(animatorHashCodes.collidedDown, true); } else if (collisionData.topCollision) { animator.SetBool(animatorHashCodes.collidedUp, true); } else { animator.SetBool(animatorHashCodes.collidedUp, false); animator.SetBool(animatorHashCodes.collidedDown, false); } // SET player sprite direction (Decide to mirror the sprite) if (moveRight && !moveLeft) { GetComponent <SpriteRenderer>().flipX = false; } else if (!moveRight && moveLeft) { GetComponent <SpriteRenderer>().flipX = true; } }