PhysX Grab Object Component
The PhysX grab object component enables a character controller to pick up physical items to carry around, drop or throw.
The component is typically attached to the same object as the camera component. When triggered, it uses a raycast along its X axis to determine which physical object to potentially pick up. When it finds a non-kinematic dynamic actor, it checks whether a grabbable item component is available. If so, the information from that component is used to determine the best anchor at which to hold the object, otherwise it uses the object’s bounding box to approximate a grab point.
When it finds a suitable grab point, it attaches a 6DOF joint to an object that is specified to be the pivot point (see
AttachTo property). That object has to have a kinematic actor and a dummy shape. The joint will then pull the grabbed item towards it and try to align its orientation according to the grabbed anchor.
The grabbed item still physically interacts with the environment. If such collisions hold the object too far back, the grab object component may decide to ‘break’ the joint and drop the object. In this case a
ezMsgPhysicsJointBroke event message is sent.
MaxGrabPointDistance: The maximum distance from this object for an individual grab point to be considered as a candidate.
CollisionLayer: The collision layer to use for raycasting to detect which object to pick.
SpringDamping: The stiffness and damping of the internally used 6DOF joint. Affects how stiff the object is held. Careful: This also determines how much force the held object can apply to other objects when you push against them. High values mean that the held object can push objects, that the character controller itself may not be able to push.
BreakDistance: If the held object deviates more than this distance from the anchor point it is attached to, the hold will break. In this case a
ezMsgPhysicsJointBrokeevent message is raised. Set to zero to disable this feature.
AttachTo: A reference to another game object, to which the held object will be attached to. The target object must have a kinematic PhysX actor (and a dummy PhysX shape), such that a joint can be attached. The reference may point to this component’s owner object. However, using a different object allows you to place the held object in a more suitable location.
GrabAnyObjectWithSize: If this is non-zero, objects that have no grabbable item component can be picked up as well, as long as their bounding box is smaller than this value.