Skip to content
Adam Graham edited this page Jul 5, 2023 · 14 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.


Why not use a tilemap?

Using a tilemap for level design does make the process of constructing the levels easier; however, it makes other aspects of the game more difficult to implement. I did use a tilemap for my first iteration of the game but as soon as I started scripting everything in the game, it become clear that a tilemap was only making the game much harder to make.

Frankly, Unity's tilemap system isn't very good if you want to have interactive, scriptable objects placed on a tilemap. For example, some of the blocks are animated when Mario hits them. There's no straightforward way to do this without jumping through some loopholes. I'm not saying it's not possible, but it becomes a lot harder and ultimately not worth it, in my opinion.

You cannot even attach a script to an object placed on the tilemap unless you install a tilemap "extras" package. I used this package in my Pacman tutorial, but I wanted to keep this tutorial as simple as possible, so I decided not to use a tilemap.


Where can I find the grid reference for stage 1-1?

The reference image can be found here: https://github.com/zigurous/unity-super-mario-tutorial/blob/main/References/1-1%20Grid.png


Enemies do not face the direction they are moving

This was an oversight on my part. Since most of the enemies are symmetrical you don't notice it, but this is not the case for Koopa. Only a couple lines of code are needed in the EntityMovement.cs script to fix the problem for all entities.

Add the following lines of code to the bottom of the FixedUpdate function:

private void FixedUpdate()
{
    //...

    if (direction.x > 0f) {
        transform.localEulerAngles = new Vector3(0f, 180f, 0f);
    } else if (direction.x < 0f) {
        transform.localEulerAngles = Vector3.zero;
    }
}

The camera is not transitioning underground after entering a pipe

The camera transitions underground when entering a pipe only if the y-position of the connection is below zero. If you believe this to be the case, but the camera is still not transitioning underground, it's likely because your entire stage is offset - the local position of the connection might be less than zero but the world position is not. Check that the parent "Stage" game object has its position reset to 0,0,0.

As an extra measure, instead of assuming the underground starts at a y-position below zero, we can add a variable to customize this as needed. Add the following variable to your SideScrolling.cs script:

public float undergroundThreshold = 0f;

Then, in the Pipe.cs script replace this line of code:

Camera.main.GetComponent<SideScrolling>().SetUnderground(connection.position.y < 0f);

with this instead:

var sideSrolling = Camera.main.GetComponent<SideScrolling>();
sideSrolling.SetUnderground(connection.position.y < sideSrolling.undergroundThreshold);

This code uses that new variable to determine if the camera should transition underground. You can customize the value of the variable on your camera game object as needed.