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 radiktus · Jan 10, 2013 at 01:55 PM · triggerdestroyenemyontriggerenterbullet

destroy a non-trigger object hitting a trigger object?

so i got this game, and the enemies got the is trigger checked so the bullet will go past them and destroy more enemies.

my game changes the bullet types though. and 1 bullet should get destroyed while hitting the is trigger enemy.

so that being said, how can i destroy an game object when it hits a "is trigger" game object?

i know how to destroy an "is trigger" objects when it got hits by a non-trigger object.

but how to do it in reverse?

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 PAEvenson · Jan 10, 2013 at 02:31 PM 1
Share

Im not sure I am following you...OnTriggerEnter passes a collider as a parameter and OnCollisionEnter passes a Collision parameter which has a collider as a member. In both functions you can access the gameobject that is hitting you.

avatar image radiktus · Jan 10, 2013 at 02:45 PM 0
Share

true. sorry but im a newbie. lets take it this way.

i got a cube that got its is trigger on.

then i throw a sphere at it that has its trigger off (just a normal collider)

the cube has a script

function OnTriggerEnter(collisionInfo:Collider){ if(collisionInfo.gameObject.tag=="bullet"){
Destroy(gameObject,0.001); }

so when the bullet hits. the cube gets destroyed right?

i was wondering how to destroy the bullet this time.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by PAEvenson · Jan 10, 2013 at 02:50 PM

Oh thats easy:

  Destroy(collisionInfo.gameObject,0.001); 
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 radiktus · Jan 10, 2013 at 02:54 PM 0
Share

im sorry im really new at this where should i attach that?

on the cube that has ontriggerenter?

avatar image PAEvenson · Jan 10, 2013 at 03:02 PM 1
Share

if youre destroying both the cube and the sphere put it directly user the Destroy(gameObject,0.001); inside the cube script

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Have bullets be destroyed when they collide with ANY collider 0 Answers

Destroy a specific object on trigger? 1 Answer

Sword Kills Enemies From Far Away 3 Answers

Distance destroy object 3 Answers

Is there anyway to make an object impenetrable? 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