Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sadowlight123 · May 18, 2017 at 01:18 PM · rigidbodycollidercharactercontroller

Difference between character controller and Rigidbody + Collider

Hello everyone , I was watching a tutorial that was talking about Physics and Collisions . We had a player that is a cylinder and we moved it with the following script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerController : MonoBehaviour {
 
 
 
     public float MoveSpeed;
     public float RotateSpeed;
 
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
 
         float V = Input.GetAxis("Vertical");
         float H = Input.GetAxis("Horizontal");
 
 
 
         transform.rotation *= Quaternion.Euler(0f, H * Time.deltaTime * RotateSpeed ,0f);
         transform.position +=  transform.forward  * MoveSpeed * Time.deltaTime * V;
 
     }
 
 
 }

The problem was that the character was going through walls and objects . The person explaining then added a character controller and used the character controller with velocity parameter instead of transform. position then have the character had gravity and collided with objects in the scene. I am really used to add a rigid body and a collider to a player whenever I need to achieve those effects. So I was wondering what the difference between those two methods were. Can anyone help explain ? Thanks in advance

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Masterio · May 18, 2017 at 08:10 PM 0
Share

Use rigidbody.velocity not transform. if you want use transform, then you need additional checks with raycasts or something like that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eno-Khaon · May 18, 2017 at 10:32 PM

Well, a Rigidbody, at a simple and fundamental level, is used to have easily-manipulatable objects in your environment. This may mean things like having balls roll around and boxes tumble.

A CharacterController, by contrast, is intended to act as an easy-to-use integration of physical interaction for a player-driven character. The logical basis is to give the player explicit control over the character's movement.

Essentially, a CharacterController lets you have a Kinematic Rigidbody that can still be stopped by other physics objects. By having all control (generally) be given exclusively to the player, you won't see any unpredictable results which might occur by having the full range of physics interactions provided by a Rigidbody.

That's not to say that a Rigidbody is a bad choice. It's really a matter of personal taste and design intent. For example, the Roll-a-ball Tutorial is based around a game design as it describes: You roll a ball around, and let it bounce off of walls as it will. Your character is the ball, but you gladly invite arbitrary movement outside the direct input the player provides.

To give an example of personal preference as a factor, I generally prefer to use a Rigidbody and define a strict set of movement rules for it. The default CharacterController inherently supports the Y-axis as its "vertical" axis, but I take particular interest in having control schemes which don't rely on a fixed direction for gravity, and apply force to individual objects myself to function as their "personal" gravity. Additionally, there are some situations where I may want a heavy environment object to push the player in a non-predetermined manner, which can be easily applied when using a Rigidbody-based character.

In short, both Rigidbody and CharacterController can fundamentally serve the same purpose. The CharacterController is designed to make it easy to hook up and control an object, but it may or may not be exactly what you're looking for in a control scheme.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sadowlight123 · May 19, 2017 at 01:21 PM 0
Share

So a character controller is like having something ready while a rigid body needs more work , thus making the rigidbody offer more customization ?

avatar image Eno-Khaon sadowlight123 · May 20, 2017 at 04:06 AM 0
Share

That's effectively the gist of it. That's not to say that a CharacterController *can't* be customized, but depending on what you're looking to do, either one can fill its role in specific ways without much additional effort.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

102 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Picking up items with Rigidbodies 2 Answers

Collision between CharacterControllers 1 Answer

Character Controller Follow me in the air 1 Answer

Guidelines for using rigidbody, collider, CharacterControllerScript, etc? 3 Answers

CharacterController vs Rigidbody (photo included) 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges