- Home /
Why does the object keep falling?
i have two objects, a drinking can and a bucket. can = rigidbody + box collider bucket = mesh collider
when the can goes into the bucket it's fine and it satys inside the bucket, but after you start moving the bucket the can starts falling down. I also tried enabling the convex option for the bucket but it's not working
how can i prevent this from happening?
tags like 'help' and 'please' really aren't that descriptive. Try and keep them on the subject of your question.
Answer by Loius · Oct 05, 2010 at 04:41 AM
You may need to alter your Physics settings -
Edit->Projet Settings->Physics
You might try decreasing Min Penetration For Penalty or increasing Solver Iteration Count.
The problem may also be caused by having a bucket that is very thin. I believe increasing Solver Iteration Count will help with that, though there's a limit to what it can do. A better solution might be to thicken the bucket walls.
If that doesn't help, you may try the parenting suggestion above, and disable the can's movement by settings its rigidbody.isKinematic = true while it's in the bucket (though that has its own disadvantages).
Answer by xToxicInferno · Aug 19, 2010 at 07:58 PM
Alright the best way to do this is put a collider (sphere maybe) inside the bucket. Now tag that collider something like 'canDetector' and make it a trigger. You can also delete the mesh renderer and filter. Now use this code and apply it to the can:
function OnTriggerEnter (other : Collider) { if(other.gameObject.tag == "canDetector") { transform.parent = other.transform; } }
function OnTriggerExit (other : Collider) { if(other.gameObject.tag == "canDetector") { transform.parent = null; } }
Or alternatively you can have it so that the bucket detects the can (that way you can have more than just the can in the bucket, which keeps you from making more scripts) which may be the better way of going about it. Also, just so you know the problem is that logic says when one object pushes against another object it will move with it (i.e. elevator goes up, you go up) but inside of Unity, if the object in motion is NOT the parent of the object inside, they will simply pass through each other. Good luck and have fun. Also make sure you detach the object from each other or problems may arise later on!
thanks, but when the can collides it just falls through the object...
Is the can a rigidbody or are you using a different method to get the can into the bucket?
Your answer
Follow this Question
Related Questions
Snapping falling objects with rigidbody to grid 1 Answer
Help with character controller collision... 2 Answers
Problem with collision - Collision.other.gameObject is obsolete 1 Answer
Having trouble turning a Transform movement into a Rigidbody force. Code included 1 Answer
Rigidbody Collision? 1 Answer