Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Paul36 · Aug 31, 2012 at 10:26 PM · collisionrigidbodycharactercontrollerbox collider

Issues with a characterController, containing a rigidbody

hi,

i am having trouble trying to make my character move and react to collisions.

I created an "empty", set a characterController on it.
Inside this empty i added a rigidbody to the character, and a box collider otherwise the character went through the plane below it.

Now, onCollisionEnter is called directly when i start the scene, how should i just combine a characterController with a rigidbody and a collider?

Also, when i set the dimensions of the charactercontroller "box", it looks ok, then i set the dimensions of the box collider, but when i start the game, the two of them change their position (like a bit on the right for the first, and a bit to the front for the second one...) Would you know why?

If i set the player to "isKinematic", and the enemy (a cube with a rigidbody (no-kinematic) inside an empty using a charactercontroller), the print in OnCollisionEnter does not show up.

When i set the position in Edit mode :

alt text

When i click on start, and reach the cube : the boxes are not located as before in edit mode, and when i touch the cube, nothing appears in the console :

alt text

 function OnCollisionEnter(collision : Collision) {
     print("test");
 }


Thanks for your help

start.png (18.7 kB)
stop.png (19.2 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by CharlesD · Sep 02, 2012 at 09:14 AM

The problem you are having is that the CharacterController script is not driven by the physics engine, and a rigidbody is. Simply combining a rigidbody and a CharacterController is subject to all kinds of annoying problems. What you want to be using is the Rigidbody FPSWalker script on the wiki instead as it is designed for manipulating a physics object. Now to answer your other questions... I believe you saw a shift in position because of the "skin width" setting on the character controller, whatever this value is set to causes the character controller to move very slightly out of where you put (this is not its purpose and it is best to leave it at its default) the shift could have also been caused by the rigidbody moving independently of the character controller. the reason OnCollisionEnter was not being called between your two rigidbodies was because I believe a kinematic rigidbody and a normal rigidbody do not both call that function, I think only the normal rigidbody does, but I may be wrong on that.

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 Paul36 · Sep 02, 2012 at 10:34 PM 0
Share

@CharlesD thanks a lot, it works great!

avatar image CharlesD · Sep 02, 2012 at 10:40 PM 0
Share

Glad to help

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

9 People are following this question.

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

Related Questions

Rigidbody: how to get collisions for the current frame ? 0 Answers

Character Controller goes through objects 2 Answers

Parenting a box collider object with a rigid body - not able to unparent 0 Answers

Prevent rigidbody being affected by character controller 2 Answers

Character Collider doesn't collide with other Colliders 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