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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Alp-Giray-Savrum · Jan 29, 2014 at 01:48 PM · collisioncolliderlookatdetectioncollisiondetection

Collision Enter one of the objects ?

Hello Again, I've been working on collision detecting. So Let me explain;

alt text

As following the code;

 var collision1 : GameObject;
 var collision2 : GameObject;
 var collision3 : GameObject;
 var collision4 : GameObject;
 
 var collisionFollow1 : Transform;
 var collisionFollow2 : Transform;
 var collisionFollow3 : Transform;
 var collisionFollow4 : Transform;
 
 
 function Update () {
 
 // I dont know :D
 
 }

I'm gonna attach theese cubes as gameobjects and, x,y,z,t points as transform.

I don't know how to detect collision ? i mean;

 if (Collision : collision1)
 {
 
 transform.LookAt(collisionFollow1);
 
 //move forward stuff
 
 }
 
 if (Collision : collision2)
 {
 
 transform.LookAt(collisionFollow2);
 
 //move forward stuff
 
 }
 
 .........

Please help :S

ekran alıntısı.jpg (221.8 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Xtro · Jan 29, 2014 at 03:37 PM

First of all, you shouldn't add more than one collider to a game object.

1) Put the colliders into separate objects.

2) Implement the OnTriggerEnter event on the moving object (maybe a spaceship)

3) When the event on the ship triggered, you can read the "other" parameter to decide which collider you've hit.

so the code will be similar to this:

 function OnTriggerEnter(other : Collider) 
 {
     if (other == collision1)
     {
         // do something
     }
     else if  (other == collision2)
     {
         // do another thing
     }
 } 
Comment
Add comment · Show 5 · 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 Xtro · Jan 30, 2014 at 09:03 PM 0
Share

Can you please mark the correct answer if you fixed that problem?

avatar image Alp-Giray-Savrum · Jan 31, 2014 at 11:00 AM 0
Share

Sorry I'was busy i newly seen your answer :S I would like to do this;

 var collision1 : GameObject;
 var collision2 : GameObject;
 var collision3 : GameObject;
 var collision4 : GameObject;
 
 var collisionFollow1 : Transform;
 var collisionFollow2 : Transform;
 var collisionFollow3 : Transform;
 var collisionFollow4 : Transform;
 
 
 function OnTriggerEnter(other : Collider) 
 {
 
 if (entered collider of the collision1)
 {
      transform.LookAt(collisionFollow1);
 }
 
 //and for other ones
 
 }
avatar image Xtro · Jan 31, 2014 at 02:39 PM 1
Share

updated my answer

avatar image Alp-Giray-Savrum · Feb 01, 2014 at 01:07 PM 0
Share

Yup, it worked ^.^

avatar image Xtro · Feb 01, 2014 at 01:31 PM 0
Share

Can you please mark this as a correct answer?

Turkish translation : $$anonymous$$olay gelsin kardeş. Zahmet olmazsa doğru cevap olarak işaretler misin ? :) :)

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

20 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

Related Questions

How do I make OnTriggerEnter() respond to just one collider? 2 Answers

clarification on collision contact points 1 Answer

Collision Checking 1 Answer

Collision detection not working properly with 2D sprites 1 Answer

Need help with collision detection 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