// Use this for initialization void Start() { currentState = PlayerState.walk; curAxis = LastAxis.none; animator = GetComponent <Animator>(); myRigidbody = GetComponent <Rigidbody2D>(); // animator.SetFloat("moveX", 0); // animator.SetFloat("moveY", -1); transform.position = startingPosition.initialValue; animator.SetFloat("moveX", startingDirection.initialValue.x); animator.SetFloat("moveY", startingDirection.initialValue.y); }
void UpdateAnimationAndMove() { if (change != Vector3.zero) { MoveCharacter(); if (curAxis == LastAxis.none) { if (change.x != 0) { curAxis = LastAxis.horizonatal; } if (change.y != 0) { curAxis = LastAxis.vertical; } } else { if (!(change.x != 0 && change.y != 0)) { if (change.x != 0) { curAxis = LastAxis.horizonatal; } else { curAxis = LastAxis.vertical; } } } if (curAxis == LastAxis.horizonatal) { animator.SetFloat("moveX", change.x); animator.SetFloat("moveY", 0); } else { animator.SetFloat("moveX", 0); animator.SetFloat("moveY", change.y); } animator.SetBool("walking", true); } else { animator.SetBool("walking", false); curAxis = LastAxis.none; } }