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 Setzer22 · Oct 23, 2011 at 03:06 PM · collisioncharactercontrollerdetection

Collisions with a character controller

Hello everyone.

I'm trying to make a simple sidescrolling shooter game.

The main character is controlled with a character controller and the enemy's bullets are in a box trigger collider. That's the code I'm using, wich is placed in the bullets:

 function OnTriggerStay (other : Collider) {
 if(other.gameObject.CompareTag("Player")){Destroy(other.gameObject);}
 } 

The script seems to work fine, but only when the main character is moving, when he's staying still, the collision doesn't seem to work fine. What I am doing wrong?

Thank you

Comment
Add comment · Show 3
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 Setzer22 · Oct 23, 2011 at 03:10 PM 0
Share

Well, Seems that attaching a kinematic rigidbody to the bullet works. Does anyone know why?

avatar image Owen-Reynolds · Oct 23, 2011 at 03:43 PM 1
Share

If you look up the Unit Collision $$anonymous$$atrix, it describes how various things hit/don'tHit each other. The short version is that if you tell Unity that two things won't move (like neither has an RB,) it won't waste time checking if they do, even if you do move them.

The funny thing is, CharacterControllers aren't in that grid. They're a weird beast that inherits from Collider but doesn't quite act like it -- even have their own OnCharControllerHit.

avatar image Setzer22 · Oct 23, 2011 at 04:08 PM 0
Share

Tank you, I didn't know that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Peter G · Oct 23, 2011 at 05:25 PM

As Owen says, the collision only happens because the Character Controller "ran into" the static bullet collider. A collider without a rigid body, Unity assumes is static. So Unity doesn't check to see if it moves into another collider.

But Unity still tests to see if any objects have moved into it hence it does detect the character controller moves into the trigger. The easiest solution is to put a kinematic rigid body on the bullet.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Collision on character controller (fps player) 0 Answers

Ceiling collision detection 0 Answers

Character Controller problem 1 Answer

CharacterController collision detection with pendulum like object 0 Answers

chronological order of collision to give a winner unity 2d 4.3 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