Basic 2D Beat em up Movement.

I’m Currently been working on a simple, beat em up style game, inspired by games like Castle Crashers, Scott Pilgrim the Game and the old D&D Capcom Brawlers. I currently have been learning Unity and although I’ve figured out how to use most of the features i still have a hard time understanding scripting, my brain just refuses to learn it for some reason, guess it douse not help i suck at Math.

public class PlayerControllerScript : MonoBehaviour
{
    public float maxSpeed = 6f;
    bool facingRight = true;

    Animator anim;

    void Start ()
    {
        anim = GetComponent<Animator> ();
    }

    void FixedUpdate ()
    {
        float move = Input.GetAxisRaw ("Horizontal");

        anim.SetFloat ("Speed", Mathf.Abs (move));

        GetComponent<Rigidbody2D>().velocity = new Vector2 (move * maxSpeed, GetComponent<Rigidbody2D>().velocity.y);

        if (move > 0 && !facingRight)
            Flip ();
        else if (move < 0 && facingRight)
            Flip ();
    }

    void Flip()
    {
        facingRight = !facingRight;
        Vector3 TheScale = transform.localScale;
        TheScale.x *= -1;
        transform.localScale = TheScale;
    }
}

This is currently the code I Frankensteined together by watching tutorials, i can move left and right and the animation changes to from walking to running with some blend tree, only thing i dont under stand is how id go about adding a Vertical axis to give the game 3D movement. ive tried a few things but the leave the script useless and Im unsure of how to apply it to my script.

if anyone has any ideas or a script that works better and is easier to edit id greatly appreciate it again im mad basic at this scripting thing so i apologize if im doing things wrong.

1 Like

I’m new to Unity3D also, and since I’m just starting out, I was thinking in order to create a 2D fighting game, like Streets of Rage for example, where the player moves from front to back and the layers of enemies and the player adjusts accordingly; to use a 3D plane (maybe make it invisible, not sure yet) that the blocks (with sprites attached) walk on, so when they move back into the screen, they’re actually moving to their left if facing right, and when moving to the front, to their right if facing right.
Then I’d need to figure out how to attach the sprites so when they have different moves, the sprites change accordingly.

The camera in the Ortho view so nothing has perspective, and at the right angle so it can view the game in 2D.

I’m still learning how to add a player, so that shows how much I have to learn about Unity. :wink: Best of luck!