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
2
Question by Kyouri · Nov 03, 2010 at 06:27 AM · objectmultiplejointcreateattach

Attaching multiple objects to one object with script.

Okay, kind of complex question here. Long story short, I'm fairly new. I started this project without realizing quite how difficult a task this section was going to be, and now I'm fairly determined to finish.

Here is the deal, I have a block that the player controls. I have code to be able to pick up and drag other objects on the field, but the final thing I need is some way to attach these objects to the main object and to each other. The goal is to have user made vehicles by picking up and dragging unowned bits on the field and sticking them on your own ship. The game is top down in a 2D environment with 3D objects. So, 4 joints are needed on every object, or so it seems.

The question is.... what's the simplest way I can handle this? My current idea for this involves using 4 joints, one for each side of the object (all objects are cubes, though they have separate functions.) However, joints can't have names, because they are components. I know I can use a function to return all of the joints in a list, and then remember the order they are returned in, but this seems like a really sketchy way of doing this. On top of that, I'm not quite sure how to do the code to fill the joints with the correct object to begin with. I may have to have every object have 4 separate rays? That seems terribly unorganized, or at very least like a lot to have in the background.

I can't use a parent/child relationship as far as I know, because the physics involved is important. Objects need to weigh the player down. For instance, a ship with one wing is going to fly in circles. This works very very well with hinges as far as I've seen from testing, but the player actually attaching objects seems incredibly difficult for me through script.

Is there an easier way of doing this that I'm not seeing? If not, how can I solve these problems? I'm sure it would be a simple job for a pro, but I am still learning. Even so, I feel it's important to challenge myself with something like this here and there, but I've been stuck on this segment for a solid week, so I am seeking help haha.

I realize this was a long post. Even if you don't have a solution for me, thank you for reading.

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
1
Best Answer

Answer by StephanK · Nov 03, 2010 at 08:44 AM

Your ship's controller script could contain an array with references to its 4 joints. Then you could define which index contains which joint and you could use that to attach objects to the correct joints. If you want cleaner code you could make an enum for the joint indexes so you could write something like this in your code: controller.joints[JointIndex.right]

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 Kyouri · Nov 03, 2010 at 09:31 PM 0
Share

Thanks, that solved almost all of my problems, but I'm fairly sure I can take it from here. You've been a great help <3.

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

No one has followed this question yet.

Related Questions

How I can create a Javascript object in a unity Script? 1 Answer

Attach object to avatar bone 1 Answer

script dosnt creat object where i want it to 1 Answer

Can't get more than one object. 1 Answer

Create object inside a game 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