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 question was closed Dec 22, 2014 at 05:36 PM by Avash for the following reason:

No good answer, found a solution

avatar image
0
Question by Avash · Dec 19, 2014 at 02:32 PM · mathintersection

How do I check for triangle triangle intersection?

I found this old code: http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/code/opttritri.txt But I need a version for unity because I can't use physics. Is there a solution for this because converting this takes time.

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 KiraSensei · Dec 19, 2014 at 02:44 PM 0
Share

Are your triangles in a 2D or 3D environment ? If they are coplanar, the test will be a lot easier. It is also possible in 3D but it will be more complicated.

avatar image Avash · Dec 19, 2014 at 04:53 PM 0
Share

3d enviroment.

1 Reply

  • Sort: 
avatar image
0

Answer by wesleywh · Dec 19, 2014 at 06:02 PM

You could use the built in function called:

OnCollisionEnter(), OnCollisionExit(), or OnCollisionStay().

Each does something different but the names should be straight forward. These require you to have a collider attached to both objects. Here is some Example code of how you could use this:

 //JavaScript - Collider
 OnCollisionEnter(other : Collision)
 {
   if(other.tag == "Player")//if there person hit is tagged player show this message in the log.
    {
      Debug.Log("Player Hit!");
    }
 }
 
 //C# - Collider
 OnCollisionEnter(Collision other)
 {
   if(other.tag == "Player")//if there person hit is tagged player show this message in the log.
    {
      Debug.Log("Player Hit!");
    }
 }

You could also use:

OnTriggerEnter(), OnTriggerExit(), OnTriggerStay().

This just checks if your object is inside a specifc area. This also requires a collider component attached to only 1 of the objects. It also needs to have the "isTrigger" tick box checked. Here is an example of how you could use this:

 //Javascript - Trigger
 OnTriggerEnter(other : Collider)
 {
   if(other.gameObject.tag == "Player")//checks if there person entering is tagged "player"
    {
      Debug.Log("Player Entered!");
    }
 }
 
 //C# - Trigger
 OnTriggerEnter(Collider other)
 {
   if(other.gameObject.tag == "Player")//checks if there person entering is tagged "player"
    {
      Debug.Log("Player Entered!");
    }
 }
Comment
Add comment · Show 1 · 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 Avash · Dec 19, 2014 at 08:51 PM 0
Share

I can't use physics. They cannot be used multiple times in one frame.

Follow this Question

Answers Answers and Comments

28 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

Related Questions

A fast triangle triangle intersection algorithm for unity? 4 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do I find the inverse cosine ??? 1 Answer

A problem with intersection detection 1 Answer

getting a sum from two scripts 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