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
1
Question by Bokaii · Mar 27, 2016 at 12:42 PM · c#collidertrigger

OnTriggerEnter with the character controller collider

So I've made a player with a character controller, and no other collider. I am trying to use the function "OnTriggerEnter" or "OnTriggerStay", but it doesn't seem to work with the character controller.

Does anyone have any idea as to why? Or maybe what else I could do

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

4 Replies

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

Answer by carlqwe · Mar 27, 2016 at 03:37 PM

Make sure that the collider that is attached to the script object is tagged as "IsTrigger"

And if it doesn't work try something like this:

 function OnTriggerStay (Col : Collider)
 {
     if(Col.tag == "Player")
     {
         //Do magic
     }
 }


Attach it to the gameobject that has the collider set to "IsTrigger" And be sure to tag the player as "Player"

If it doesnt work post some pictures and explain more what is happening

~carlqwe

Comment
Add comment · 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
1

Answer by meat5000 · Mar 27, 2016 at 01:37 PM

There is this method

http://docs.unity3d.com/ScriptReference/CharacterController.OnControllerColliderHit.html

for collisions on CharacterController.

I notice in the docs, under 'Inherited Members' that "isTrigger" is actually listed. Perhaps this will actually work to change the CC collider to a trigger? May cause problems, who knows, you can but only try.

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 Bokaii · Mar 27, 2016 at 02:01 PM -1
Share

The thing is, I am using a character controller - not a rigidbody

avatar image
-1

Answer by giorashc · Mar 27, 2016 at 01:23 PM

In order for an OnTrigger... event to occur your game object (player) must have at least one collider (marked as trigger in your case). So attach a collider component to your player (or character controller) depicting the area which will cause a trigger (and mark the collider as trigger in the inspector)

Comment
Add comment · Show 3 · 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 Bokaii · Mar 27, 2016 at 02:01 PM 0
Share

This still doesn't work - Nothing happens... :c

avatar image giorashc Bokaii · Mar 27, 2016 at 02:13 PM 0
Share

can you post the player hierarchy and the inspector content? are you sure you have a collider on your play/controller and that the other game object (the one you expect a collision with) has a collider as well?

avatar image Bokaii giorashc · Mar 27, 2016 at 02:26 PM 1
Share

It turns out the trigger was too small - even though it did touch the buttom of the player. That was the only problem. Why this occoured? I don't know, but it did - But it's fixed now :D

avatar image
0

Answer by xTyler73 · Nov 18, 2018 at 08:11 PM

By default, colliders are set to the same size as as the object you add it to, so the trigger could end up being inside the object. You'll need to offset its "Center" property so that it's big enough to actually collide with the player without being too small.

Just realized the answer is here in a reply, but not marked as the best answer so I missed it on my first reading. Hope this helps someone.

Comment
Add comment · 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

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

123 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 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

Destory/Collect object to open door 1 Answer

Using two trigger colliders 1 Answer

Trigger help! 0 Answers

Multiple Cars not working 1 Answer

Adding force relative to the distance from an object 1 Answer


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