Home > Net >  Unity3d - Rigidbody vs CharacterController vs transform.Translate for Sidescroller
Unity3d - Rigidbody vs CharacterController vs transform.Translate for Sidescroller

Time:04-11

I recently dive into Unity and for my first personal project, I plan to make a 3d sidescroller. The sidescroller however will behave like 2d platformer/sidescroller (only x and y axis). I am wondering which is the best movement controll for the player. Upon searching myself, I found different suggestion by using CharacterController, Rigidbody or even the simple transform.Translate. I am struggling to understand which to use and what each best used for. Thank you in advance for any explanation.

CodePudding user response:

  • Well is any Physics / collision detection etc involved?

    → this basically rules out going through anything in Transform as it would break the collision detection and general feel/correctness of the physics engine.

  • Rigidbody responds to forces like gravity and PhysicsMaterials providing bounce and friction etc. and usually you apply values more event based (like explosions etc).

    There are a lot of different APIs of how do add forces and velocities to rigidbody objects which gives you a lot of control.

    However, for continuous user input this sometimes is a bit strange to control since you either have to use forces which are strange to calculate (e.g. if you want have a maximum velocity) or absolute velocity input which kinda breaks with the idea of a physics controlled object.

  • The CharacterController on the other hand does not automatically respond to all those physics. It is basically something in between and using Move allows to still respond and interact with collisions.

    Any gravity, bounce, friction and other forces you need to calculate your self and apply accordingly via passing the resulting movement (= velocity) into the Move method every frame.

    An alternative is SimpleMove which rather applies the gravity automatically.

CodePudding user response:

Well I don't know between Rigidbody and CharacterController. But I would definitely not use Transform.translate, at least if it's more than just jumping and moving left right. The reason why is mostly Physics and the feel of it.

I think you'll have to use the CharacterController but I'm really not sure

CodePudding user response:

this Unity Which Movement You Should Choose should help you a lot and answer your questions. Advice: for future plan to create your own movement logic without using any build-in components that is very good practice.

  • Related