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 mpkostek · Dec 06, 2018 at 11:09 PM · instantiatephysics2dcollider2dcollision2d

Ignore collision before instantiating

I am trying to instantiate a bullet which fires from the center of my 2D character. The bullet is colliding with the player that fired it because it spawns before I can call IgnoreCollision. It can't be a trigger because I need it to bounce off walls. I can't ignore layers because I want the bullet to collide with other players. Any ideas?

Comment
Add comment · Show 2
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 Vega4Life · Dec 06, 2018 at 11:25 PM 0
Share

Can you move the instantiate point to be a little bit out front of the character, thus missing the collider?


Add a bullet spawn point gameObject on your player, then just use that to instantiate your bullet. It's essentially a spawn point or socket.

avatar image mpkostek Vega4Life · Dec 06, 2018 at 11:28 PM 0
Share

I'd rather spawn from the center of my character for right now. I need to be able to tell the object that I don't want it to collide with the player that fired it before I instantiate it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Vega4Life · Dec 07, 2018 at 12:10 AM

I just ran a test with this:


         if(Input.GetKeyDown(KeyCode.Space))
         {
             Bullet bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);
             Collider bulletCollider = bullet.GetComponent<Collider>();
             Physics.IgnoreCollision(spawnerCollider, bulletCollider);
         }


It spawns inside of the spawner, doesn't move, doesn't call OnCollision events. So, not sure whats going on with yours.

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 mpkostek · Dec 07, 2018 at 12:19 AM 0
Share

Hm, that is pretty much exactly what I am doing. I just tried out my layer for each player and each player's bullets idea and that seems to be working just fine, just a bit messy I guess.

avatar image Vega4Life mpkostek · Dec 07, 2018 at 12:33 AM 0
Share

Sometimes you gotta be janky :)

avatar image Cornelis-de-Jager Vega4Life · Dec 07, 2018 at 05:00 AM 0
Share

@Vega4Life changed your comment to an answer.

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

Updated Unity, 2D Colliders not working. OnTriggerEnter2D not working 0 Answers

Is Overlap Circle Supposed to return inactive colliders? 1 Answer

Bullets go through collider even with continuous collision detection! 0 Answers

Collision with instantiated non-moving objects. 1 Answer

Edge Collider issue 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