void changeSprite(Vector2 moveDir, bool isHolding) { if (moveDir.y > 0) { currentSpriteTuple = sprites_back; } else if (moveDir.y < 0) { currentSpriteTuple = sprites_front; } else if (moveDir != Vector2.zero) { currentSpriteTuple = sprites_side; } if (moveDir != Vector2.zero) { spriteRenderer.flipX = moveDir.x > 0; } Sprite spriteToSet; spriteToSet = isHolding ? currentSpriteTuple.carry : currentSpriteTuple.normal; if (spriteRenderer.sprite != spriteToSet) { spriteRenderer.sprite = spriteToSet; } }
private void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); currentSpriteTuple = sprites_front; }