How Picking Up Objects Work in Arms race but it’s a play
This system uses extensively UMotion’s Animation Events: https://www.youtube.com/watch?v=IWV1K2j8IZ0
The system has two major components:
CarryableObject
A CarryableObject has a target and a list of possible targets. If the object has a target set, it will automatically match position and rotation of the target. This component is set on the objects that should be picked up and put down.
No reparenting is done to avoid issues with changing parents mid-flight. This is not quite as performant, but it works in a pinch.
The list of targets is entirely so that it can work with UMotion; UMotion only allows Animation Event functions to have int / string / bool parameters, so instead of setting the target object directly, we set it indirectly by referencing the transform from the list index. Every possible ‘resting’ place for an object should be in the list of targets, as the object ‘hops’ between them.
Most of the time, you don’t call the CarryableObject’s functions directly, and instead call them via the CarryableObjectController:
CarryableObjectController
A CarryableObjectcontroller is placed on the actor (usually a humanoid) that is moving around objects, and more importantly, the rig that the UMotion animations are created on.
Also has a list of objects, for a similar purpose as the CarryableObject’s list of targets – it’s meant for changing objects to interact with within the confines of UMotion’s Animation Events.
And a hand parameter, that determines when the actor themselves pick up an object.
There’s a PickupObject
function to make the object’s target the hand, as well as a more generic SetObjectPinnedTarget
function that lets the actor set the object’s target
Usage
The way to use this system is roughly:
- At the beginning of the play, set the CarryableObjects’ targets to their initial place on the stage.
- When an actor picks up an object, create an AnimationEvent that calls into CarryableObjectController’s
PickupObject
function, and thus parent the object to the actor’s hand. - When an actor puts down an object, call
SetObjectPinnedTarget
to the new position that the object should be with an AnimationEvent.