void Update() { if (FloatUtils.CloseEnough(source.time, source.clip.length)) { source.time = introTime; } }
void FixedUpdate() { moveDirection.Set(0, 0); if (eat.dead || eat.eating) { return; } if (!FloatUtils.CloseEnough(Input.GetAxis("Horizontal"), 0f)) { moveDirection.Set(Input.GetAxis("Horizontal") * speed, 0); } if (!FloatUtils.CloseEnough(Input.GetAxis("Vertical"), 0f)) { moveDirection.Set(moveDirection.x, Input.GetAxis("Vertical") * speed); } if (transform.position.y < minYPosition.position.y) { moveDirection.Set(moveDirection.x, Mathf.Max(0, moveDirection.y)); } rb.MovePosition(rb.position + moveDirection * Time.fixedDeltaTime); if (moveDirection.x < 0) { direction = Direction.W; } else if (moveDirection.x > 0) { direction = Direction.E; } else if (FloatUtils.CloseEnough(moveDirection.x, 0, 0.01f)) { direction = Direction.S; } if (direction != lastDirection) { lastDirection = direction; anim.SetInteger("Direction", (int)direction); } }