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 TheNiluseqqq · Jun 15, 2020 at 06:31 AM · collisionmovementcollidertag

plain problem with collider. begginer in unity

Hey! I made a 2D game based on shooting. The problem is that the bullets fly through everything! I used this void

void OnTriggerEnter2D(Collider2D obj) { if (obj.gameObject.tag == "obstacle") { Destroy(this.gameObject); } } But this not work D: information: Bullet is set on trigger, Obstacle is set on plain, box collider tag is correct, move in bullet and player is same

idk what i make wrong maybe i use wrong void or i wrong use this? Idk iam begginer in unity and c# if you wanna more information write thanks! Active and usefull friends @onlineight @ShadyProductions @xxnickiiixx @sarahnorthway

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 Artik2442 · Jun 15, 2020 at 07:29 AM

It is because of the speed of your bullet...

Your bullet go so fast that unity have some trouble to calculate the OnTrigger or OnCollision event!

The easiest way to fix that is to use rb2D.AddForce and not rb2D.velocity or transform.Translate(transform.right * speed).

With that, you have to find the perfect force speed so the trigger/collider can be detected by unity.

Hope it helps...

Comment
Add comment · Show 2 · 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 Artik2442 · Jun 15, 2020 at 07:30 AM 0
Share

I forgot to tell that the rb2D.AddForce is for the movement of the bullet.

avatar image Artik2442 · Jun 15, 2020 at 07:30 AM 0
Share

You can set the mesh collider of your plain to convex too!

avatar image
0

Answer by TheNiluseqqq · Jun 15, 2020 at 12:26 PM

Releasing the bullet does nothing. Could you show me how to use rb2D.AddForce to make my object move? @Artik2442

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 Artik2442 · Jun 16, 2020 at 08:18 AM 0
Share

When you are Instantiating the bullet, do the bullet has a Rigidbody2D Component?

Because your bullet will need one. Set the mass to a very low value, you can choose one you want (because your bullet will drop)

In your script, when you are instantiating:

  GameObject bulletInstantiated = Instantiate(bullet, bulletPos, bulletRot); //Here you are instantiating the bullet
  bulletInstantiated.GetComponent<Rigidbody2D>().AddForce(transform.right * ForceSpeed)//You are adding a force that will make the bullet movement
avatar image Artik2442 Artik2442 · Jun 16, 2020 at 08:19 AM 0
Share

The ForceSpeed will be the value you will change to have the perfect speed of your bullet.

avatar image Artik2442 · Jun 17, 2020 at 09:37 AM 0
Share

Are you on a 2D game? If yes, look if your plane Z position is equal to the Z position of your bullet.

avatar image
0

Answer by Hessen19 · Jun 16, 2020 at 03:48 PM

Yes the bullet release didn't helped me even a bit. Now its getting a bit frustrated upsers

Comment
Add comment · Show 2 · 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 Artik2442 · Jun 17, 2020 at 09:34 AM 0
Share

Remember to set the $$anonymous$$esh Collider of your Plane to Convex!

avatar image Artik2442 Artik2442 · Jun 17, 2020 at 09:36 AM 0
Share

Are you on a 3D game?

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

262 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Stopping my player from moving when hitting a wall. 5 Answers

Is CompareTag faster than checking directly the GameObject? 1 Answer

Play annimation on collision not working. 1 Answer

Collision, tags, and triggers 1 Answer

What's wrong with OnCollisionEnter? 2 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