Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 smarjanovicng · Mar 12, 2019 at 09:45 AM · collision3dboardgamechecking

Check if 3 same colliders on a line?

alt text

Hello, can someone tell me if its possible to check when the blue line connecting these 3 figures (instantiated clones of a prefab) is indeed containing 3 same colored figures? I was thinking of colliders but again i have a problem how to know if there are 3 Figure colliders on one connecting line. Thank you!

capture.png (87.8 kB)
Comment
Add comment · Show 1
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 WarmedxMints · Mar 12, 2019 at 01:28 PM 0
Share

You could make the points where they spawn a node and have the nodes check what their neighbours contain.

3 Replies

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

Answer by mlnczk · Mar 12, 2019 at 02:28 PM

So if I understand correctly you just want to check if those three prefabs have the same color in line? If yes then you can try: public Transform firstPrefab; public Transform secondPrefab; public Transform thirdPrefab;

 private void CheckIfSameColor(){
     if(firstPrefab.GetComponent<Material>().color == secondPrefab.GetComponent<Material>().color && firstPrefab.GetComponent<Material>().color == thirdPrefab.GetComponent<Material>().color){
          //we got a match
     }
 }

its not the pretties and if you have way more prefabs on the screen it would be way better to store prefab's materials and operate on them. If only possibility to success is to have all three of them at same color then checking first with second and first with third is enough.

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 YiYiBaBa · Mar 12, 2019 at 03:07 PM

Whether it's on a line Judge two objects x,y Whether it's the same or not Or if the Angle between the vectors is 0

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 smarjanovicng · Mar 13, 2019 at 09:32 AM

I tried that, works as expected with slight modifications, but found another solution since i needed the boolean going false after end of players turn, i used lists to see if the count is equal to 3 figures, and after the turn just cleared the list. Gonna post the code here if anyone else needs it. Thanks for the input anyway! Much love!

 public List<Collider> collidedObjectsP1 = new List<Collider>();
 public List<Collider> collidedObjectsP2 = new List<Collider>();
 public int numberP1;
 public int numberP2;
 #endregion

 #region Update
 private void Update()
 {
     CheckPhases();
     numberP1 = collidedObjectsP1.Count;
     numberP2 = collidedObjectsP2.Count;

     if (Input.GetKeyDown(KeyCode.S))
     {
         Debug.Log(numberP1);
         Debug.Log(numberP1);
     }
 }
 #endregion

 #region On Trigger Enter
 //On trigger enter add the players figure to the list
 private void OnTriggerEnter(Collider other)
 {
     if((other.gameObject.tag == "Player1Figure") )
     {
         collidedObjectsP1.Add(other);
     }

     if ((other.gameObject.tag == "Player2Figure"))
     {
         collidedObjectsP2.Add(other);
     }
 }
 #endregion

 #region On Trigger Exit
 private void OnTriggerExit(Collider other)
 {
     collidedObjectsP1.Remove(other);
     collidedObjectsP2.Remove(other);
 }
 #endregion
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

174 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with Collision (3D) 2 Answers

How to detect when an object goes past (so it looks like it touches) a UI element. 1 Answer

More realistic physics? 0 Answers

Downhill bike suspension 1 Answer

Turn off script of object clones 2 Answers


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