Hello. I have recently been looking into building a 2d platformer using Unity and was hoping to get some input as to what type of system I should use for the main character and their movements.
I currently want something like Mario,braid,limbo,fez, something similar. I know/understand that they have built their own engines but I am also certain that something similar can be achieved in unity.
I have found three options that will work, but each have their own advantages and drawbacks.
Ridged bodies
Character Controller
Raycast
I am leaning towards Raycast just because that will give me the most control over what the character does, but I am having difficulties with slopes and platforms moving up/down and looking normal.
What do you think would be the best option and if I am missing any please feel free to speak up.
It depends of course on the context of the game you are creating, if you don’t require specific physics based functions then I wouldn’t suggest using the rigidbody approach. This will hand off the control to the physics engine and any sort of translations or manual, so to speak, movements of your character will result in undefined behavior. (Translating through walls, improper velocities, directional anomalies). But if physics is what you are looking for (I am also making a 2D platformer based on physics puzzles for example) rigidbody is your best choice for realistic physics calculations.
Character controllers on the other hand are easier to use so to speak, they don’t require knowledge of physics and work in a more simplified manner, that is they are easier to use in certain ways of predictability (given you don’t have a physics background) and maneuverability.
Character controllers also don’t use your oncollision functions. They inherit from Collider and will have the function; however, if you do not have a rigidbody it won’t fire the event handler. This thread has an example at the end of function message passing, which is somewhat expensive but it will work for character controller collision detection. But also there’s this function. I haven’t used the character controller, I as previously stated use the rigidbody. So I can’t speak for the effectiveness of that method.
I don’t know much about using raycast. :(.
But to summarize my point: If you need real physics use rigidbodies with the caveats expressed above, but if you don’t or you want to script your own physics and circumvent the physics engine of unity use character controllers I would think.