Search Unity

Character Controller vs Rigidbody

Discussion in '2D' started by amprost, Dec 3, 2020.

  1. amprost

    amprost

    Joined:
    Sep 12, 2020
    Posts:
    3
    So I'm having a beginner growing pain. I've used rigidbody for most of my previous projects up until now. I recently started using an asset for creating 2d characters which comes with a basic character control script which uses character controller.

    The issue I'm seeing right now is that the character controller does not move in the Y axis as a rigidbody does. This means that my character will not climb slopes as it moves along the x axis.

    Below is a screenshot of 2 characters. The robot comes from the standard asset pack and uses rigidbody and the other comes from the 2d character asset pack and uses character controller. I want to use the character controller to learn more about it but I'm not sure why it won't change y values as it moves along the x axis. Do I need to change the scripting that I have for the basic character control to allow it to change y axis values?
     

    Attached Files:

  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,464
    Basically, Rigidbodies deal with physics and the Character Controller (as far as i know), does not. So if you want to deal with irregular slopes and pathing, using physics to push rigidbodies is best. If everything was perfectly flat with no slopes, a character controller would be fine.

    To sort-of answer your question, yes you could change the character controller script to increase the Y value as the X changes, but if the slope changes at all it will not work well.
     
    amprost likes this.
  3. amprost

    amprost

    Joined:
    Sep 12, 2020
    Posts:
    3
    That's what I figured. Thanks!