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
0
Question by tmar2 · Oct 27, 2012 at 05:18 PM · physicsobjectsjointsfixed

How can I access all game objects connected in a cluster by fixedjoints?

I am new to Unity, but not new to game development. I have been trying for some time now to set up a sort of clustering system for some objects in my game.

Basically, I have multiple moving objects in my world. They will all be of the same object type and will be running the same base script. When they hit one another, they stick to one another and I already have fixed joints being created to hold the objects together. My question is:

How can I, from the script of one object, access each of the other objects which are connected to one another via fixed joints? It seems like an easy problem to solve, but the tricky part is that object1 could be connected to object2, and object2 could be connected to object3 and object4. I need to be able to access all four objects, in code, from any one of the objects. For instance, if one is destroyed, I want to inherently destroy the other three.

Any help is much appreciated. :) P.S. I'm using Javascript.

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

Answer by Montraydavis · Oct 27, 2012 at 06:27 PM

I would suggesting finding objects of type x.

http://docs.unity3d.com/Documentation/ScriptReference/Object.FindObjectsOfType.html

 function OnMouseDown () {
     var hinges : HingeJoint[] = FindObjectsOfType(HingeJoint) as HingeJoint[];
     for (var hinge : HingeJoint in hinges) {
         if ( hingeConnected ){
             code......
         }
     }
 }

Obviously, Joints or w/e needs to be of type (whatever you are wanting), and hingeConnected depends on your way of detecting this... I don't have your code, so, you will have to do that part .

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 tmar2 · Oct 27, 2012 at 06:43 PM 0
Share

I appreciate the response, though I should have mentioned that there will be more than one cluster going on at the same time between the same object types. Using this method would probably cause problems and destroy or affect joints and objects that are in different clusters, which wouldn't be good. :( I do appreciate the information, however.

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

10 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

Related Questions

HELP PLEASE PROBLEM WITH JOITS 0 Answers

consecutive angularxdrive.positionspring.equals() not working 0 Answers

Bend object with physics interaction 0 Answers

Rigidbody hover, bodies connected with joints should hover together. 0 Answers

Problem with joints 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