Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by flohallo · Sep 08, 2016 at 06:38 PM · gameobjectscalegameobjectsjointsjoint

How to create piston-like object which change scale over time and are connected to other objects with Joints?

Hello, so I have GameObjects which look something like this. (consisting of primitive spheres and cylinders)

I want the cylinders, which connect the spheres, to change in Y-Scale over time. in order to make it look like the cylinders is some kind of pistons (so the cylinders should continuously grow and then shrink again). The top and bottom side of the cylinders should never be visible and always hidden inside the sphere. So the spheres should move attached to the ends of the cylinder.

I tried to achieve this by writing a simple script that changes the Y-scale over time and connecting the spheres to the cylinders with joints, but the result wasn't satisfying at all. (I tried FixedJoints, CharacterJoints, SpringJoints and HingeJoints, but none worked). Currently in this attempt, I am using FixedJoints, each sphere has a Rigidbody (Use Gravity and Is Kinematic both set to false) and a SphereCollider, and each Cylinder has also a Rigidbody with Use Gravity set to true, and Is Kinematic set to false, but no Collider.

I don't know a lot about joints, I looked at the manual and watched two videos (including the one from Unity itself), but am not really smarter than before. The SpringJoint has Connected Anchor values. One way to solve my problem would probably be to calculate that Anchor every frame anew (would it?), but that seemed like a lot of effort for such a task. Isn't there a more convenient way?

I also thought about hiding a second cylinder with the same dimension as the first one, inside the first one, and only change the position of this second cylinder, but that also seemed like a weird solution. Furthermore, the cylinder might be more than twice as long in its extended state than when contracted.

Thank you for reading my question!

EDIT: I made an animation how I want the result to look, to make it more clear. (Except for the buggy string things on the top right corner of the thing, didn't know how to remove that, sorry)

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 doublemax · Sep 09, 2016 at 08:01 AM 0
Share

What's the final purpose of this object? Until now it sounds like you could forget about joints, colliders and everything and just calculate everything yourself. (You have a triangle with three known sides)

avatar image flohallo doublemax · Sep 09, 2016 at 08:16 AM 0
Share

I want to create such "creatures" procedurally and let them race against each other. I think I'll use the solution I wrote as an answer. But thanks a lot for responding!

1 Reply

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

Answer by flohallo · Sep 09, 2016 at 08:13 AM

Alright, so a quick update: I asked in another forum, and the solution I got was to just "fake" the cylinders. So the cylinders have only a mesh renderer, and the spheres are directly connected with each other with spring joints. Seems way more convenient than my proposed way!

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

82 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

Related Questions

How to make gameobject appear in center of camera irrespective of it's side?? 0 Answers

NullReferenceException when attempting to call a GameObject from within PointerEventData 1 Answer

Is it safe to instantiate a GameObject and then change it's components? 1 Answer

how to assign different Gameobject to a single variable during run time using c#? 1 Answer

How to keep Configurable Joint from stretching? 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