Game Design and Development 2
2D Platformer

share ›
‹ links

Below are the top discussions from Reddit that mention this online Coursera course from Michigan State University.

Offered by Michigan State University. If you love games and want to learn how to make them, then this course is your second step down that ... Enroll for free.

Reddsera may receive an affiliate commission if you enroll in a paid course after using these buttons to visit Coursera. Thank you for using these buttons to support Reddsera.

Taught by
Brian Winn
Full Professor
and 6 more instructors

Offered by
Michigan State University

Reddit Posts and Comments

0 posts • 1 mentions • top 1 shown below

r/UnityHelp • comment
1 points • Bonejob

How I would manage this is to determine when they transition to the Falling state and note the Transform Y position for the current height. Then on collision, I would calculate the damage based upon fall distance.

Your scripts look like you have just started throwing code at the problem without doing any research. I would suggest you look into State Machines and Character Controllers.

https://game-developers.org/how-to-make-a-state-machine-character-controller-advanced-unity-tutorial/

Dapper Dino is using Visual Scripting to illustrate the concept. I would suggest this will help you understand the process.

It does not have to be as complex as illustrated for example here is my boilerplate code to manage the states of my player character.

private PlayerState GetState()
    {
        return state;
    }

    /// <summary>
    /// Description:
    /// Sets the player's current state
    /// Input: 
    /// none
    /// Return: 
    /// void (no return)
    /// </summary>
    /// <param name="newState">The PlayerState to set the current state to</param>
    private void SetState(PlayerState newState)
    {
        state = newState;
    }

    /// <summary>
    /// Description:
    /// Determines which state is appropriate for the player currently
    /// Input: 
    /// none
    /// Return: 
    /// void (no return)
    /// </summary>
    private void DetermineState()
    {
        if (playerHealth.currentHealth <= 0)
        {
            SetState(PlayerState.Dead);
        }
        else if (grounded)
        {
            if (playerRigidbody.velocity.magnitude > 0)
            {
                SetState(PlayerState.Walk);
            }
            else
            {
                SetState(PlayerState.Idle);
            }
            if (!jumping)
            {
                timesJumped = 0;
            }
        }
        else
        {
            if (jumping)
            {
                SetState(PlayerState.Jump);
            }
            else
            {
                SetState(PlayerState.Fall);
            }
        }
}

You are conceptually missing whole sections of the process, and I would suggest that you examine this course

https://www.coursera.org/learn/game-design-and-development-2

It is specific to 2d platformers, to be fair I would start with the first course in the series which is a 2d space shooter game.

You can sign up for free get all the code assets and parts and then decide if you want to pay the 60 odd dollars to complete it.