I am designing chines dice game , I need to keep 5 dice in Cup all the time and while the cup drag or shake the dice position change accordingly. I made dice as child of Cup but when i drag the cup , dice and cup move together without any collision between dice and Cup. if i didn't make dice as child of cup when i drag the Cup , dice throw out the cup.
I use box collide for dice and mesh collier for my cup.
kindly please help me how to keep dice always in cup with maintain collision feature between dice and mesh of cup.
Dainal, it seems that your Cup and Dice are not responding to physics. Make sure that both the cup and the dice are rigidbodies.
Also, remember that physics will only come into effect when you "play" the game. If you drag the cup or dice in the editor, they will pass through each other, despite having colliders turned on.
This will help:
make sure that you have choosed "generate colliders" for your models before put them into your scene.
Hi sajidfarooq , Thanks for your reply , I have used Rigidbody for both dice and cup and I use touch screen in play mode to drag the cup but dice pass through the cup , let me explain more, I create objects on 3D Max and then add them to project. when I add cup to my project I add mesh collides and Regidbody and set my mesh filter and materials based on object that i created in 3D max , in mesh collides checked the Convex.
1- Can you tell me is it correct that i define dice as child of cup ?
2- if not do have any suggestion or solution to keep them in cup all the time?
3- how to configure engine (collide) to make collision between the side of cup and dice?
Unparent the dice. They need to move regardless of cup position, as this is the effect you want to achieve.
To make sure that the dice don't get out of the cup, create an invisible box collider on top of the cup and parent it to the cup. When you decide to throw the dice, de-activate the box so the dice can get out.
Looking for helpfull hands with an action/RPG fan game -- link
Remember to have a nice day and smile!
1 and 2 have already been answered above. For 3, remember not to move your dice directly using transform.Translate. You should use physics (forces), otherwise the results are physically inaccurate and can cause collision detection to fail.
Last edited by sajidfarooq; 05-25-2012 at 02:46 AM. Reason: Added code example
Thanks , I create invisible box as parent of Cup but dice come up of this box and when i run the game.when this box hit with other dice collide is happened, I think box collision just work while collide from outside of box not inside box. I Dont want to throw dice out of cup.
I also create empty box in 3d Max and add to my Project, and use mesh collide, and rigidbody. the dice pass through this object from side but not from bottom and I couldnt realize that. Could please help me to solve this problem
try use on cup :- mesh collide smooth spere
- not convex
on dice : - box collider
- rigidbody with interpolate and continous dynamic. and gravity
move only cup.