Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

The concept is brilliantly innovative, accompanied by captivating graphics, and offers an enjoyable gaming experience. To enhance user satisfaction, consider incorporating hints at each stage to assist when players are stuck and uncertain about their next steps also the swimming movement can be improved more I have done it In my own game.

//Use the logic I have made :

//The code can be more improve, but Its results are good.

private bool facingLeft = false;

float horizontalInput = Input.GetAxis("Horizontal");

float verticalInput = Input.GetAxis("Vertical");

  Vector2 movement = new Vector2(horizontalInput, verticalInput);

  movement = movement.normalized;

   // Flip the character sprite based on movement direction

        float angle = Mathf.Atan2(verticalInput, horizontalInput) * Mathf.Rad2Deg;

        // Flip the angle if the x-coordinate is negative

        if (movement.x > 0f)

        {

            // Apply the rotation and location to the object

            transform.localScale = new Vector3(1, 1, 1); // Facing right

            facingLeft = false;

            if (movement.y > 0f)

            {

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

            }

            else if (movement.y < 0f)

            {

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

            }

        }

        else if (movement.x < 0f)

        {

            // Apply the rotation and location to the object

            transform.localScale = new Vector3(-1, 1, 1); // Facing Left

            facingLeft = true;

            angle += 180f;

            if (movement.y > 0f)

            {

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

            }

            else if (movement.y < 0f)

            {

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

            }

        }

        else if (movement.y > 0f)

        {

            if (!facingLeft)

            {

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

                // Facing Left

            }

            else

            {

                angle += 180f;

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

            }

        }

        else if (movement.y < 0f)

        {

            if (!facingLeft)

            {

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

                // Facing Left

            }

            else

            {

                angle += 180f;

                transform.rotation = Quaternion.Euler(0f, 0f, angle);

            }

        }

        else if (!facingLeft && movement.y == 0f)

        {

            // Apply the rotation to the object

            transform.localScale = new Vector3(1, 1, 1); // Facing right

            transform.rotation = Quaternion.Euler(0f, 0f, 0f);

        }

        else if (facingLeft && movement.y == 0f)

        {

            transform.localScale = new Vector3(-1, 1, 1); // Facing left

            transform.rotation = Quaternion.Euler(0f, 0f, 0f);

        }