- Home /
How to make a bead shaped object pass through a string
I am trying to make this bead shaped object pass through a cylindrical helix. I have tried adding all kinds of colliders and tweaking their properties, both objects have a RigidBody, but the sphere just falls through the helix instead of passing(flowing) through it.Need Help! I have posted a couple of images for your reference. Thank You. ![alt text][2]
if you exa$$anonymous$$e the mesh collider of the helix does it follow the mesh appropriately, and does the mesh collider of the "bead" follow the shape
I don't think you can make this work. Generally two mesh colliders cannot collide. You can 'solve' this problem by marking them 'convex', but I think you will lose your hole in your bead if you do it this way. It might be possible to crate a mesh that rides the string (not a bead with a hole). $$anonymous$$ore info on mesh colliders here:
http://docs.unity3d.com/Documentation/Components/class-$$anonymous$$eshCollider.htm
You could simulate this behavior by defining a path and then moving the bead along the path. iTween is one solution for define a path and moving an object along that path. There are more packages in the asset store for path following as well as a number of posts on the issue here on UA.
Thanks man! iTween worked! But I am still unsatisfied as the Physics Engine isn't able to do this thing.
This might work if you only use a mesh collider for one of them - use basic box or sphere colliders to approximate either the coil or the bead.
But dealing with the physics forces and friction and indeter$$anonymous$$ate nature of physics would be a nightmare - much easier to go with iTween unless the player is supposed to apply forces to it or something.
Using the physics engine wouldn't be bad, but it would require more work. The helix would need a compound collider, which is made by adding children to the gameobject and giving those children appropriate colliders, such as capsules. Re-positioning of the colliders would allow you to make a spiral which would work.
Compound colliders are also mentioned with capsule colliders here: http://docs.unity3d.com/Documentation/Components/class-CapsuleCollider.html
Answer by s_guy · Jul 20, 2013 at 11:00 AM
I presume you mean to have the bead pass over or around the unmoving helix so that it will follow a spiral path. (The helix is going through the bead.)
The physics engine isn't good at dealing with problems where complex surfaces are in continuous contact. Even if you get it working, the parts will probably just rattle around and not get the smooth result you probably want. The physics engine is better at sparse scenes where convex objects occasionally collide with each other.
For this, it would be better to make sure the two parts don't have physics collisions and just animate the bead's position.
This is the formula for position over time t of a regular spiral up the Z axis:
x(t) = cos(t)
y(t) = sin(t)
z(t) = t
Check it out:
(snagged from Wikipedia)
You'll have to multiply t by some factor and each line by some factor to get a perfect fit with your exact helix.
It might look something like this:
x(t) = cos(t) * ConeRate * t
y(t) = sin(t) * ConeRate * t
z(t) = t * StretchRate
...where ConeRate is a value that affects how big the spirals get and StretchRate is a value that affects how tight the helix is along its axis.
Answer by temptest123 · Jul 20, 2013 at 11:33 AM
both your meshes are concave, so you would need concave mesh colliders (untick the convex checkbox). But unity does not compute collisions between concave meshcolliders (as such collisions are costly).
Answer by THEAK472009 · Jul 20, 2013 at 01:02 PM
The iTween method was bound to work perfectly.The capsule collider method worked perfectly. The animation method too worked perfectly! I added a trail renderer for a better visual effect. Thank you all for helping!
Your answer
Follow this Question
Related Questions
Strange Physics being applied to objects issue. 1 Answer
Two even colliders causing bounce at transition 1 Answer
Collision Issue - Walk Through Object 0 Answers
Make Ray hit own collider 1 Answer
Calculate the normal of a collider 1 Answer