Basic mario style platform walking script

I want to make a basic walking script similar to a mario style game. I want the character to only be able to walk forward and backwards, and to be able to jump. I took a break from scripting so im kinda rough around the edges if anyone could help me out or reference a wiki that would be great. -Thanks

A tutorial for 2D gameplay is here: . It's about everything to do with making a 2D game, but I don't think it walks you through the scripting process. Since it has an example project though, you can take a look at the scripts they use and how they work.

Good luck!

here's one approach that doesn't use physics or a character controller:

this script would go on your character (after you finish it)

public var runSpeed : float = 3;
public var runSpeedDamping : float = 0.5;
public var jumpSpeed : float = 4; // I made these values up,
public var fallSpeed : float = 4; // they will need to be tweaked

private var isGrounded : boolean = false;
private var velocity : Vector2 =;

function Update () {
    // figure out if you're touching the ground
    // you could use a downward raycast or colliders/triggers
    isGrounded = ...

    // figure out how fast to move based on input
    velocity.x = Mathf.Lerp(velocity.x,
                    runSpeed * Input.GetAxis("Horizontal"),

    // jumping/falling
    if (isGrounded) {
        // if you're on the ground, stop the vertical movement
        velocity.y = 0;
        if (Input.GetButtonDown("Jump")) {
            // if you hit jump then give it some vertical speed
            velocity.y = jumpSpeed;
    } else {
        // if you're not touching the ground, reduce your vertical
        // speed a little bit every frame.
        velocity.y -= fallSpeed * Time.deltaTime;

    // apply the movement using only the X and Y axes
    var movementVector : Vector3 = new Vector3(
            velocity.x * Time.deltaTime,
            velocity.y * Time.deltaTime,
    // You should use some raycasts here to make sure you won't collide
    // with anything and if you do adjust your movement distance 
    // you can use movementVector.Normalize to get the direction of a ray
    // and movementVector.magnitude to get the length for the ray
    // if your raycast hits then `hit.distance * movementVector.Normalize`
    // will give you the new movement vector

Also take a look at this link.. It contains 5 small 2-d game examples and goes through all the scripting.

Its in C# though...