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
2
Question by SmileFace100 1 · Mar 26, 2011 at 01:51 PM · collision

How to enable/disable "Is Trigger" on collision enter ?

Hi

I want to enable "Is Trigger" if the enemies hit each other and disable it if they hit the player. so the player can die.

i think "on collision enter" will do it but i can't handle the scripting stuff

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
5
Best Answer

Answer by Meater6 · Mar 26, 2011 at 02:18 PM

Tag all the enemies "Enemy" and tag the player as "Player". Then use this script:

function OnCollisionEnter(collision : Collision) { if(collision.transform.tag == "Enemy" && !transform.collider.isTrigger){ transform.collider.isTrigger = true; } }

function OnTriggerEnter(trigCollision : Collider){ if(trigCollision.transform.tag == "Player" && transform.collider.isTrigger){
transform.collider.isTrigger = false; } }

I hope this helps. :)

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 SmileFace100 1 · Mar 26, 2011 at 03:41 PM 1
Share

Thanks a lot (:

avatar image Meater6 · Mar 26, 2011 at 03:54 PM 1
Share

I would like if you up voted this, if it is very helpful.

avatar image chiako · Feb 04, 2013 at 08:17 AM 1
Share

where should i put this script?

avatar image
1

Answer by quinnbot · Jul 01, 2015 at 05:44 PM

Super old thread but I thought I'd point out the Physics Collision Matrix which does exactly what you need here without any scripting

http://docs.unity3d.com/Manual/LayerBasedCollision.html

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 Unamine · Mar 26, 2011 at 02:09 PM

Try using GetComponent to activate and deactivate the properties of a GameObject

Steps:

1 - Create a variable to identify the gameObject may be through the object tag

2 - Create another variable that is looking for a component within the previous variable

3-and enable or disable the property IsTrigger of the component.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

support not detected collision and Leasehold 0 Answers

Disable a script on collision 2 Answers

Do a collider only with certain taged objects 2 Answers

Script to dectect collision and say what it collided with every time it collides with it 2 Answers

Implementing 2D Sprite Collisions 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