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 callen · Feb 07, 2014 at 01:47 AM · physicscharacter controlling

Can someone please explain Character Controller use?

I've read all the documentation and answers here about it, and I still don't really get why this doesn't work...

I have a character who I need to move locally with Character Controller, and remotely by just setting its transform (thru my own serialization code). Both use the same prefab, but in Start() I disabled the character controller if the player is a remote player.

When I do that, I don't get my trigger collision events activated by the player. This is even though I also have a mesh collider and kinematic rigidbody on it. It only works if the (unused) character controller is active.

Is the controller somehow disabling the collision that should occur with the separate collider? Or since the mesh collider is a child of the character controller's object, does that make it stop working? Or do I really not understand how Unity physics is designed (most likely answer)?

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 Kiloblargh · Feb 07, 2014 at 02:04 AM

If you used gameObject.SetActive (false) it will also make any children inactive. component.enabled will not.

Your problem is probably not with the CharacterController's collider but the mesh collider. The mesh collider needs to be convex, and it should have the correct layer / tag.

A Debug.Log message will let you know if the mesh collider is ever sending trigger enter events at all.

To explain the Character Controller's use: Its main use is for beginner FPS tutorials to make it look as creating controllable characters in Unity is easier / more user-friendly than it really is. If you are making a real game, at some point you will realize you can't make a Character Controller do everything you want it to do and you're going to have to write a custom script to replace it.

Comment
Add comment · Show 1 · 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 callen · Feb 07, 2014 at 09:40 PM 0
Share

Yeah I still don't get it. I understand what you say about "easier than it really is" but if underneath the CharController is just setting the transform, shouldn't it trigger for local and remote players (if the remote player is me setting the transform manually)?

Yeah I used debugging, the first line of my Pickup.OnTriggerStay (started using Stay ins$$anonymous$$d of Enter, just to be sure) just had Debug.Log("trig") and when I move over it with the local player the console spits out trig, when I watch a remote player move there nothing happens at all.

Both players come from the same prefab, and I've manually checked the editor to see their Layers and Tags are the same.

Yup I was just disabling the component, so according to what you said that shouldn't affect anything. And yet...

Since posting I found out that if I set everything up as described before, but I DON'T include the line "GetComponent<CharacterController>().enabled = false" the trigger DOES occur. Since the object being triggered is the pickup, shouldn't the dwarf's collider trigger it no matter what the CharController is doing?

I fixed the issue that made me start disabling remote character controllers, so it works now, but I would really love to know why?

(With your comment about convex colliders, I may have a hypothesis. I thought I was using the default Colliders unity puts on certain prefabs, like a box collider, but actually its a mesh collider using the built-in primitive cube. Likewise the coin uses an icosphere mesh collider, and mesh colliders are not created with the convex checkbox checked. I remember two non-convex meshes won't collide, at least not without more work. So maybe I just didn't realize there were different types of colliders, and I can change both and have it working!)

(Edit: That was it! I initially created Quads which come with $$anonymous$$esh Colliders by default. Changing them to Box and Sphere Colliders has fixed everything. Thank you so much for the insight!)

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

19 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

Related Questions

Character Controller's performance for massive groups 0 Answers

Prevent physics judder in an elevator/moving vertical platform? 1 Answer

Question regarding character controllers and slopes 0 Answers

2D 360 degress platformer example needed 0 Answers

Rigidbody physics behaving differently from editor to build 0 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