Game Development Reference
In-Depth Information
Thus far, I have neglected the properties related to breaking joints and adding torque. I
know they can be very intriguing, so let's quickly try them on the chain and rope.
Breaking Force Example
Open
Chain.ccb
, and select the joint that connects the last chain segment with the ball.
This is most likely the last
CCPhysicsPivotJoint
instance in the Timeline.
The
Breaking force
field on the
Item Properties
tab is set to a stress threshold that the
joint is able to withstand. If the joint stress exceeds the arbitrary value entered in
Breaking
force
, the joint will be removed. Change the radio button next to
Breaking force
so that
you can enter a value in the text field next to it. As for the value, enter
1060
. If you ask
me how I determined that value: trial and error. It should work if you change the joint
properties as instructed; otherwise, you may find you need to use a higher or lower
value—see the following discussion.
Caution
Max force
must be either unlimited or set to a value equal to or higher
than
Breaking force
.
Try this in the game with a chain instance whose rotation is 0 so that it does not swing.
Swinging alone might cause the breaking force to be exceeded, because even just a
slightly lower
Breaking force
value of
1050
would always sever the connection. If you get
this right, merely touching the ball or chain with the player will cause the joint to disap-
pear, and the ball will drop from the chain.
Now there's a problem here. The
Breaking force
setting is not very reliable and thus not
suitable for triggered events that have to happen. For instance, if touching the ball should
always drop it, you should implement a collision method rather than using collision types.
Breaking force is also tedious to determine, but it's not impossible to determine it if you
follow this principle:
Enter an arbitrary high value for
Breaking force
, say,
100
.
Check if the joint in question breaks. Ideally, the joint bodies should be at
rest.
If the joint breaks, double the value and try again.
Search WWH ::
Custom Search