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
1
Question by mabit · May 29, 2012 at 02:02 AM · collidercollisionsadvice

Help with a collision problem.

I have T shaped objects that can collide with each other arranged in a 10x10 grid. If the player clicks one it rotates and if it collides then the object it collides with rotates and a chain reaction happens.

My conundrum is this:

My objects are Instantiated in a random direction so some are colliding as soon as they are in the game scene. This is starting the reaction immediately.

Can anyone think of a way to have the objects ignore collisions when they are Instantiated but will be affected after the mouse has been clicked on one of the objects collides.

I have tried to deactivate the colliders until the mouse is clicked. That was the same result as above.

I cant make them ignore the first collision as not all objects will be colliding on start up.

Any suggestions any one has will be appreciated.

Added Info

Here is a link to an image of the start up...the ones colliding should not start rotating until they have have been collided with another object after it has rotated, even though they are all ready colliding.

http://dl.dropbox.com/u/5130962/Atoms.png

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 ByteSheep · May 29, 2012 at 03:59 AM 0
Share

I would probably go with your original approach: deactivate the colliders until the mouse is clicked. This should be the simplest way really.. you could set the collider to a trigger or deactivate the collider entirely, the answer of $$anonymous$$ $$anonymous$$ehreron on this question might help - http://answers.unity3d.com/questions/10883/how-do-i-disable-collision-for-an-object.html

avatar image Fattie · May 29, 2012 at 03:54 PM 0
Share

Aldo's trick of clever algorithmic trick of propogating fixes only one-way, will get you through something like this. Hope it helps!

2 Replies

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

Answer by aldonaletto · May 29, 2012 at 12:06 PM

Since the random rotation seems to be always a multiple of 90, you could do the following:
1- Instantiate the object with Is Trigger set and at some random rotation;
2- If a OnTriggerEnter event occurs, rotate 90 degrees clockwise (for instance);
3- To avoid more than one atom rotating to runaway from the collision, name each atom with an increasing index, and only rotate the one with "greater" name;
4- When the user clicks one atom, set all atoms' isTrigger to false;

Atoms creator script:

var size = 10; // grid size

function CreateAtoms(){ var n = 0; // name index for (var x=0; x< size; x++){ for (var z=0; z< size; z++){ var pos: Vector3 = ... // calculate the position according to x and z var rot: Quaternion = Quaternion.Euler(0, 90 * Random.Range(0, 4), 0); var atom = Instantiate(atomPrefab, pos, rot); atom.tag = "Atom"; // tag atoms as "Atom" to help collecting them atom.name = "Atom" + n.ToString(); // give it an increasing number n += 1; atom.collider.isTrigger = true; // it's a trigger at first } } } Atom script:

function OnTriggerEnter(other: Collider){ // if some collision occurs... if (name > other.name){ // only the one with higher index will rotate transform.Rotate(0, 90, 0); } }

function OnMouseDown(){ // when any atom is clicked... // get all of them in an array... var atoms: GameObject[] = GameObject.FindGameObjectsWithTag("Atom"); for (var atom: GameObject in atoms){ atom.collider.isTrigger = false; // and enable collisions } // do what you want to do here when the atom is clicked }

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 mabit · May 29, 2012 at 09:24 PM 0
Share

Thanks for that, I am not a coder so will take me a good few hours to digest that info. But I really appreciate the work. Thanks

avatar image
0

Answer by Artmann · May 29, 2012 at 11:06 AM

I would create an area that's reserved for new T-Shapes, so when an T-Shape is in the specified area it can't rotate.

if(!inStartArea()) Rotate();

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 mabit · May 29, 2012 at 11:18 AM 0
Share

When I remove the start area as any of the objects is clickable then I am back at the same issue :(

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Detecting multiple gameobjects 1 Answer

Collisions occassionaly fail. 4 Answers

Creating a Barrier 1 Answer

Collider Shape 1 Answer

Rigid Body Collision 0 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