• 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 Basso · Aug 13, 2013 at 09:39 AM · collidertriggerrubikscube

Move everything within Collider around an specific angle

I have a rubiks cube like constructionand now i want to move it like a rubiks cube. ive got a collider for every move that is possible within a rubiks cube, so speaking about a 5x5 rubix cube there are 15 colliders, but i have no clue how i can get every object within the collider and mover it around a specific angle for 90°.

im looking into the trigger section right now but it seems im looking for the wrong section or im just to stupid to get it, not sure right now.

can you give my some hints maybe?

would be grateful....

achhandrian

EDIT: Got some hints from a friend but im still a bit clueless.... and got some

NullReferenceException WuerfelRotation.Update () (at Assets/Scripts/WuerfelRotation.cs:25)

with this script.

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using System;
 
 public class Wuerfelinha : MonoBehaviour 
 {
     public System.Collections.Generic.List <GameObject> inhalt = new System.Collections.Generic.List<GameObject>();
     
     
     public void FixedUpdate()
     {
         for (int i = 0; i < inhalt.Count; i++)
         {
             if (inhalt[i] == null || ! inhalt[i].active )
             {
                 inhalt.RemoveAt(i);
                 i = 0;
             }
         }
     }
     
     public void OnTriggerEnter(Collider Kollision)
     {
         if (! inhalt.Contains(Kollision.gameObject))
         {
             inhalt .Add(Kollision.gameObject);
         }
     }
     
     public void OnTriggerExit(Collider Kollision)
     {
         if (inhalt.Contains(Kollision.gameObject))
         {
             inhalt.Remove(Kollision.gameObject);
         }
     }
 
 }

 using UnityEngine;
 using System.Collections;
  
 public class WuerfelRotation : MonoBehaviour {
     
     public GameObject other;
     public string ColliderName;
     
     void Update(){        
         
           switch(Random.Range(1, 4)){
             case 1:
                 ColliderName = ("ColliderA" + Random.Range(1, CreateDiceV1.Anzahl+1));
                 other = GameObject.Find(("ColliderA" + Random.Range(1, CreateDiceV1.Anzahl+1)));
                 other.collider.isTrigger = true;
                 break;
             case 2:
                 ColliderName = ("ColliderB" + Random.Range(1, CreateDiceV1.Anzahl+1));
                 other = GameObject.Find(("ColliderB" + Random.Range(1, CreateDiceV1.Anzahl+1))); 
                 other.collider.isTrigger = true;
                 break;
             case 3:
                 ColliderName = ("ColliderC" + Random.Range(1, CreateDiceV1.Anzahl+1));
                 other =  GameObject.Find(("ColliderC" + Random.Range(1, CreateDiceV1.Anzahl+1)));
                 other.collider.isTrigger = true;
                 break;
             default:
                 //Debug.Log("ERROR");
                 break;
         }
         
         if (other.GetComponent<Wuerfelinha>())
         {
             Wuerfelinha bla = other.GetComponent<Wuerfelinha>();
             for ( int i = 0; i < bla.inhalt.Count; i++)
             {
                 //bla.inhalt[i].;
             }
             other.collider.isTrigger = false;
         }
         
         
     }
 }
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
0
Best Answer

Answer by Xtro · Aug 13, 2013 at 01:57 PM

I didn't read your code but I think you should parent all the objects under a central object (the center of the rotation) and you should rotate this central object. After the rotation, you can break the parenting links back to normal.

Comment
Add comment · Show 6 · 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 Basso · Aug 13, 2013 at 06:22 PM 0
Share

i would still need to get everything insides this collider to do that because its constantly changing......

avatar image Xtro · Aug 13, 2013 at 06:23 PM 0
Share

you can use the trigger(enter and exit) events to collect the objects inside the collider(trigger) actively.

avatar image Basso · Aug 13, 2013 at 08:24 PM 0
Share

yeah that what im trying to do and cant get running....

avatar image Xtro · Aug 13, 2013 at 08:36 PM 0
Share

did you test even if the trigger events are firing ?? try to see if you have a problem in your scene setup by adding some debug code in the trigger events.

avatar image Basso · Aug 15, 2013 at 06:54 AM 0
Share

tested it today and no seems the trigger events are not working.... :(

tested a bit the trigger is getting fired with a character controller but i need it fired with another gameobject.....

ok adding a rigid body work, last thing i need to to do make the collidors into a trigger and back so iu need to get the specific collider by the name.....

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Can't click gameobject when over another trigger? 1 Answer

Physics Possibilities?: Angles, Penetration, Exceptions 4 Answers

Trigger-based vehicle ai? 1 Answer

Trigger Spawning? 1 Answer

Temporarily ignore collisions between player and enemies 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