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
3
Question by ina · Dec 14, 2010 at 06:01 AM · meshproceduraljointspring

Create the visual spring in Unity?

There's the SpringJoint, but what if you want a vivid spring that expands and compresses (in 3 degrees of freedom) connecting the two objects?

Should I:

A: 1) import 3d spring mesh. 2) fudge some procedural compress parameters

B: procedurally generate the spring mesh completely

C: a better way?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by psdev · Nov 08, 2011 at 11:09 PM

I know this is an old question, but in case anyone has a similar query, this is what I would do:

  • Create a spring shaped model with morphs in your 3D modeler which stretch and compress the spring to its maximums
  • Use Mega-fiers to import the morphs into Unity
  • Buy and use Mega-fiers from the Asset store and use its morphing capabilities
  • Drive the morphing of the spring to null points (empty game objects) driven by a Unity SprintJoint
  • You can also use Mega-fiers to deform the spring bending while it is morphing

That way Unity's physics create the motion (which looks good from my tests) and the spring model will look good because you are just animating the morph via physics.

By the way, I've found the trick to getting SpringJoints to look right is to put visible Gizmos on the NullPoints that are the anchor and weight of the SpringJoint and make Gizmos visible during runtime while you play with the numbers to figure out the correct range to set the Spring force, mass and dampers...

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
avatar image
1

Answer by Bunny83 · Dec 28, 2010 at 05:22 AM

I'm not an artist but as programmer i don't recommend creating a spring procedurally(It would be a nasty piece of work and don't look great i think ;) ).

It would be easier to create the spring in max/maya/whatever and attach two bones to your spring. One at each end and then skin the vertices to both bones (the weights lineary adjusted). Imported into Unity you get a SkinnedMeshRenderer and your two bones as seperate GameObjects. Now you can joint them together as you like and if it's skinned right it should bend and strech the right way.

I should append that i never used spring joints before, but basically that's how it should work.

Good luck

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
avatar image
1

Answer by s4vi0r · Dec 29, 2010 at 03:28 PM

Hi ina,

I'm not sure how good you are wanting it to look but one simple solution could be adjusting the Y scale via sine wave.

You might have to tinker with this code a bit. I don't have time to go test it atm.

Update()
{
    var speed = 5;
    var amplitude = 2;
    transform.localScale.y += amplitude * Mathf.Sin(Time.time * speed);
}

This will scale your object up and down replicating a spring. c(=

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 Bunny83 · Dec 30, 2010 at 05:17 AM 0
Share

Sure, that's the easy way, but he want the spring to move in "3 degrees of freedom". So it should also bend to the side

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

1 Person is following this question.

avatar image

Related Questions

A ball and spring - multiple degrees of freedom 0 Answers

How to colorize a face of a Mesh 0 Answers

How to connect two spheres one to stay on top of another which is rotating moveing one (player body , head) 0 Answers

How to make two objects connected by a joint collide? 1 Answer

creating a mesh procedurally 4 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