Skip to content
Adam Graham edited this page Jul 5, 2023 · 11 revisions

Links

FAQs


Is the source project free to use?

Yes, you are free to use the project for any purpose. However, keep in mind that copyright and/or trademark laws can still apply to the original material since many of the games in my tutorials were not originally authored by me. I open source my own code for the community to learn from, but the project is intended for educational purposes only.


How to prevent too many movement inputs

If you press the movement inputs too quickly, frogger can become misaligned with the grid and possibly go out of bounds in unexpected ways. This is caused when a new leap animation is performed while the previous leap animation is still ongoing. One way to fix this is to add a cooldown after frogger leaps so they have to wait before leaping again. The cooldown will last only for the duration of the leap animation to finish.

Let's first add a new variable to our Frogger class:

private bool cooldown;

Then, in the Move function we will only proceed with the movement code if not on cooldown:

private void Move(Vector3 direction)
{
    if (cooldown) {
        return;
    }

    //...
}

Finally, in the Leap coroutine function, we will set the the cooldown to true and false, respectively:

private IEnumerator Leap(Vector3 destination)
{
    //...
    // Start cooldown at beginning of coroutine
    cooldown = true;

    while (elapsed < duration)
    {
        // existing code...
        yield return null;
    }
    
    //...
    // Stop cooldown at end of coroutine
    cooldown = false;
}

My sprites are not displaying in the game

There could be a few different reasons for this, but the main reason is likely that you have not changed the Sorting Layer and/or Order in Layer properties on your SpriteRenderer component. These properties determine the order in which sprites are rendered. Your sprites might be rendering behind your background elements causing them not to be seen.

I recommend using the following Order in Layer values for your sprites:

  • 1: Frogger
  • -1: Road/Water
  • 0: Everything else