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 Sericet · Jan 05, 2012 at 10:17 PM · collisions

Collision problem Ignorecollision

I have these objects that are being spawned. I do not want them to collide with reach other unless they are a certain height above the ground. Is it possible to ignore collisions between these objects until they have reaches a certain height? I don't want to turn off collisions completely because they are allow to collide with other objects in the scene. I gave them all the tag "Enemy". Thanks for any help in advance!

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

2 Replies

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

Answer by by0log1c · Jan 05, 2012 at 10:32 PM

Should have started there : Unity Scripting Reference : Physics.IgnoreCollision, heh.

Edit: Any script can call Physics.IgnoreCollision(collider1,collider2,state) at anytime. collider1 and collider2 are Collider component reference found through script using GetComponent() or dragged through the inspector. state is a boolean(true/fale) turning collision on or off.

var myCollider:Collider; var otherCollider:Collider;

function CollisionOff():void { Physics.IgnoreCollision(myCollider,otherCollider,false); }

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 Sericet · Jan 05, 2012 at 11:22 PM 0
Share

Ok, that helps a lot. So these objects that are being instantiated are able to ignore each other? I am worried that when I use this script I will get an error saying the other object doesn't exist yet or it can't be the same object. Also am I able to refer to these colliders using tags?

avatar image by0log1c · Jan 05, 2012 at 11:49 PM 0
Share

Yes, indirectly. You'll first get the GameObjects using GameObject.FindGameObjectsWithTag("Enemy") then loop through the array and use GetComponent() to retrieve the collider. With that, call Physics.IgnoreCollision().

avatar image Sericet · Jan 06, 2012 at 02:31 AM 0
Share

I have this all setup. Here is the issue, hopefully you can give some suggestions. I am getting an error saying that both myCollider and othercollider need to be active (I.E instantiated).

Since this isn't something I can control due to the nature of the game is there a way to check and see if these objects are in existance and then I can run this script in an If statement. Thanks for all the help so far

avatar image
0

Answer by Sericet · Jan 05, 2012 at 10:44 PM

I have already read that and it didn't make sense to me. I am new to programming and wasn't sure how to do it for my senario. Your answer did not help.

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 by0log1c · Jan 05, 2012 at 11:00 PM 0
Share

Please do not post comment as answer.

avatar image Sericet · Jan 05, 2012 at 11:18 PM 0
Share

Sorry, didn't see that I could comment

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Checking Child collisions through parents 1 Answer

Collision angle of collided 1 Answer

Can I force collisions to be checked before Start or manually check collisions? 2 Answers

2D platformer levers and moving platforms question. 0 Answers

Applying a force to multiple rigidbodies at once. 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