Hi, we are facing some problems using HingeJoint. Referring to the picture attachment below:
Ball is launching towards another group of balls
The launched ball sticks on contact, creating a hinge joint between the two.
With the remaining momentum, there are two possible outcome that occurs randomly.
3a. A stiff joint is created between the balls that just made contact, and the momentum causes the whole collection of 4 balls to swing in counter-clockwise direction.
3b. A joint is created between the balls that just made contact, and the momentum causes the single black ball to swing in counter-clockwise direction with the other ball as pivot.
We want the behavior to be like 3b consistently, but right now it is random. Any idea what we are doing wrong?
Additional data:
All in X-Y plane
OnCollisionEnter is used between balls
Each ball has a ConfigurableJoint attached to remove ball rotations about X or Y axis, params for it are:
anchor: (0, 0, 0)
axis: (1, 0, 0)
secondary axis:
XMotion : Free
YMotion : Free
ZMotion : Free
Angular XMotion: Locked
Angular YMotion: Locked
Angular ZMotion: Free
configuredInWorldSpace: true
Adjacent balls are connected by a HingeJoint, params for which are:
anchor: (0, 0, 0)
axis: (0, 0, 1)
First of all I think you need only one HingeJoint in this case. I would make sure that only one is created and you always attach it to the black ball and the 2nd target is always an “old” ball.
If you just use OnCollisionEnter without additional checks, then you get random order - one time it callback will be called first for black ball, another time it might be called on the white ball first.
Btw if you don’t want you white balls to move, I think you could mark them as kinematic (once they’re stuck) to prevent any motion.
We were able to achieve the behavior we wanted by using two ConfigurableJoints for each ball - one to lock X,Y and Z motions, and the other to lock angularX and angularY motions.
Using only one ConfigurableJoint we tried anchor (0,0,0), axis (1,0,0) and secondary axis(0,1,0), but the ball would sometimes rotate around X or Y axis. What are we doing wrong?
Is there a way to set the distance between two balls to be an exact value at the moment collision happens and the joint subsequently created? We don’t want little gaps or overlaps between balls when they are connected (which happens sometimes)
We tried setting the position manually but that would clear the ball’s momentum.