// Update is called once per frame void Update() { if (followingTarget != null) { FollowTargetObject(); } // resolve move positions ResolveMoveCharacter(); // use the character mover to move characterMover.inputX = xVelocity; characterMover.inputY = yVelocity; charDirection.SetDirection(xVelocity, yVelocity); // resolve state bools // to do: make this a state machine if (yVelocity == 0 && xVelocity == 0) { isMoving = false; } else { isMoving = true; } // update animation states // TODO: make this respect changes instead of calling every frame characterAnimator.UpdateAnimationState(isMoving, isAttacking, (float)charDirection.currentCharacterDirection); }
// Update is called once per frame void Update() { // using controller input to move player characterMover.inputY = Input.GetAxis("Vertical") / 4; characterMover.inputX = Input.GetAxis("Horizontal") / 4; if (Input.GetAxis("Vertical") == 0 && Input.GetAxis("Horizontal") == 0) { isMoving = false; } else { isMoving = true; } // work out if we are attacking this will work but not like this // TODO: change to use a state machine if (Input.GetAxis("Action") > 0) { isAttacking = true; worldInteracter.TryHit(charDirection.getVectorDirection()); } else { isAttacking = false; } // set direction and animation states charDirection.SetDirection(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); characterAnimator.UpdateAnimationState(isMoving, isAttacking, (float)charDirection.currentCharacterDirection); }