Search Unity

Is it possible to edit the first person controller for a 2D game? If so, how?

Discussion in '2D' started by OctoSloths, Nov 10, 2014.

  1. OctoSloths

    OctoSloths

    Joined:
    Oct 28, 2014
    Posts:
    2
    I'm trying to make a 2D controller and I'm very new to coding. I was wondering if there was anyway to make it so the first person controller can only move in the x and y directions? I've already taken off the mouse look script so that's no longer a problem.
     
  2. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    333
    post the script and we might be able to help, you can use the
    Code (csharp):
    1.  code syntax by using the [Code] in the forum
     
  3. WidmerNoel

    WidmerNoel

    Joined:
    Jun 3, 2014
    Posts:
    66
    Hi!
    I wouldn't try that. 3D Controllers in Unity are usually based upon the Box2D physics engine. By that I mean that objects are moved by using rigidbody.AddForce. In 2D games you often want "pixel perfect movement", wich can be achieved by not using AddForce. If you read about the movement in Super Mario Galaxy, you'll find out, that even if SMG is a 3D game the developers used a non-physically-based movement. (Because they needed more control) When developing 2D games you most often will find it a bad idea to use physics. I recommend checking out prime31's 2D Character Controller on git, wich works very well by default. In there you'll find a physical and a non-physical movement script. Keep in mind that they are NOT using AddForce in any case. A physical movement in 2D is often used when talking about translating, instead of re-setting the characters position in each frame.