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
0
Question by Bigproblem01 · May 28, 2017 at 11:35 AM · collisionphysicstriggercharactercontrollerignorecollision

Bullets colliding with Character Controller

Hi,

I'm not even sure the title is the issue but that's my best guess so far. I have a first person shooter where I'm using a character controller for my player and I can shoot bullets from the gun which have a SphereCollider set to Trigger. When I jump, if I shoot down, there a weird physics behavior which I can't understand. Here's a video demonstration.

I tried these things already to no avail: - disabling all the layer flags in physics so that player and bullets don't collide - using Physics.IgnoreCollisions (Player's character controller, bullets sphere collider) - I tried printing CharacterController.OnControllerColliderHit to the console, it shows floor, walls, etc. but bullets don't show up for some reason.

If I disable the sphere collider on bullets, then the behavior disappears, which means those sphere colliders (set to trigger) collide with something (I suspect my character controller) but I don't know how to disable this collision.

Help is appreciated!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Cuttlas-U · May 28, 2017 at 12:01 PM

hi; i think i had the same problem in my game ;

1 solution for this can be assigning different Layers to Bullet and player then go to Edit > Project Setting > Physics and disable the connection between the bullet and player layer , this way it will not Collide with the player collider;

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 Bigproblem01 · May 28, 2017 at 06:01 PM 0
Share

Thanks for the reply, but as I already stated I tried disabling the physics flags and it doesn't solve the issue unfortunately.

avatar image
0

Answer by Bigproblem01 · May 30, 2017 at 05:48 PM

does anyone have more suggestions?

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
0

Answer by melsy · Jun 15, 2017 at 03:02 PM

Are you by chance adding force to the bullets on impact? What does the code look like

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 Bigproblem01 · Jun 15, 2017 at 08:28 PM 0
Share

No I'm not. The bullets are shot this way:

 void Start()
     {
         GetComponent<Rigidbody> ().AddForce (transform.forward * bulletSpeed * 100);
     }
 
     void OnTriggerEnter(Collider _hitObject)
     {
         GetComponent<SphereCollider> ().enabled = false;
         Instantiate(Object$$anonymous$$anager.instance.bulletImpactParticle, gameObject.transform.position, Quaternion.identity);
         if (_hitObject.tag == "Enemy") 
         {
             _hitObject.GetComponentInParent<Enemy> ().TakeDamage (bulletDamage);
         }
 
         Destroy (gameObject);
     }

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

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

How do I detect when two CharacterControllers collide? 0 Answers

Character Controller meets Rigidbody 1 Answer

Voxel engine physics 3rd person character controller 1 Answer

Simulating the Character Controller? 0 Answers

CharacterController collision disabled when modifying center 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