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
2
Question by Jungle · Apr 21, 2013 at 01:43 PM · collisioncollidercharactercontroller

Can static objects detect collisions

Is it possible for a static object to detect collisions with a player using a character controller, i am currently using 'OnControllerColliderHit()' on the player script to find the static object and trigger any scripted event that i want.

Want i want to know is if the static object's script can detect when the character controller collides with it and trigger the event itself rather than the player script having to reference the static object and tell it what to do.

I have tried using 'OnCollisionEnter()' on the static object's script but it seem to only detect the collision if the the object i want to be stationary is moving, rather than when something else collides with it.

Thanks for any help

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Bunny83 · Apr 21, 2013 at 10:39 PM

No, not really. static objects can't detect anything. Only active components like a Rigidbody or the CharacterController can. True collisions are handled by the physics system. This always requires at least one rigidbody.

In general all moving objects should have a rigidbody. static object are per definition "static" and should never move and therefor can't detect collisions. It's always the rigidbody that detects collisions, even when you move a static collider (which you shouldn't) into a rigidbody the collision is detected by the rigidbody but only when the rigidbody is awake. If a RB doesn't move it falls asleep. When you move the rigidbody it wakes up again.

Take a look at the table at the bottom of this page

The CharacterController is another case. It doesn't produce collision messages since from the Physics system's point of view it's a static collider. The CC does it's own collision detection (OnControllerColliderHit). For more details see the CharacterController component page

Comment
Add comment · Show 6 · 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 Jungle · Apr 21, 2013 at 10:48 PM 0
Share

So your basically saying that if I want something like a stationary object (maybe a target) to know if it has been hit by something else that is using a character controller for movement, then either the stationary object needs a rigidbody attached or the character controller needs to tell the target "hey i collided with you, do something"

avatar image Bunny83 · Apr 21, 2013 at 11:13 PM 0
Share

Yes, that would be a way. You could use Send$$anonymous$$essage in OnControllerColliderHit to invoke your own "event" on the hit-object.

avatar image Jungle · Apr 21, 2013 at 11:20 PM 0
Share

Seems like there should be a way for an object itself to know if something else has hit it, but I guess I'm just being picky :P

Thanks for the help

avatar image Nition · Jun 24, 2014 at 02:43 AM 0
Share

There is. You can set the target's collider to Is Trigger and you'll get the OnTrigger events. Here's a chart of what triggers what: http://answers.unity3d.com/storage/attachments/2050-interactionmatrix.png

Edit: Character colliders are a special case. They'll fire OnTrigger events on trigger colliders even though there's no rigidbody involved. They won't fire OnCollision events though.

avatar image Bunny83 · Jun 24, 2014 at 02:54 AM 0
Share

@Nition:
Why linking a custom uploaded image when there is the manual. Anyways, for any collision or trigger messagees you need a rigidbody. The character controller doesn't use the physics system. From the physicssystem's point of view the CharacterController is just a CapsuleCollider.

Show more comments
avatar image
0

Answer by cbranch101 · Apr 21, 2013 at 03:04 PM

It should, as long as you have colliders in both both objects. Are you sure you have a collider in your static object?

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 Jungle · Apr 21, 2013 at 10:20 PM 0
Share

Yes I definitely have a collider on the static object

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

13 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

Related Questions

Getting Character controller to fit model? 0 Answers

When using a character controller for the player, can other colliders be used alongside the character controller? 1 Answer

OnCollisionEnter does not work 4 Answers

Character Collider doesn't collide with other Colliders 2 Answers

GameObjects glitching through other Objects when being held 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