Items
Objects that an agent can interact with in any way, should get the Item component. Currently, this allows items to be picked up and dropped.
Picking Up and Dropping Items
Items can be picked up with a Agent
MeshSockets.SocketId.RightHand
MeshSockets.SocketId.LeftHand
MeshSockets.SocketId.RightLowerArm
MeshSockets.SocketId.LeftLowerArm
MeshSockets.SocketId.RightUpperArm
MeshSockets.SocketId.LeftUpperArm
MeshSockets.SocketId.RightBack
MeshSockets.SocketId.LeftBack
MeshSockets.SocketId.HipsFrontLeft
MeshSockets.SocketId.HipsFrontRight
MeshSockets.SocketId.HipsBackLeft
MeshSockets.SocketId.HipsBackRight
MeshSockets.SocketId.LeftLowerArm
MeshSockets.SocketId.AdditionalSocket1
toMeshSockets.SocketId.AdditionalSocket10
The position and rotation of existing sockets can be changed by modifying the corresponding game objects in the Agent Prefab under Agent > AnimationRigging > MeshSockets
. Up to 10 additional Sockets can also be added there, by creating a new game object with a Multi-Parent Constraint
and the MeshMeshSockets.SocketId.AdditionalSocketX
can be selected and then also be used in the code.
When the LeftHand or RightHand socket is selected a simple inverse kinematics (IK) animation on the hand will be played, for all other sockets the animation will be played on the right hand.
The item can also specify a Grab
Items can be dropped with a Agent
Requirements
- The agent needs the
MeshSockets
andRigBuilder
components, as well as everything that is part of theAnimationRigging
child object in the agent prefab, in which the Sockets for the item positions are defined as well as the inverse kinematics animation for the grab animation. For more information on the used Unity Package see animation rigging package. - Items that should be picked up need the Item component.
- The Items Can
Be method needs to return true.Picked Up - (optional) A Grab
Target can be defined, that's where the agent will move its hand position and rotation wise and what attaches to the specified socked when picking the object up. The default is the local zero coordinates of the item.
- The Items Can
Example Scenes
The framework contains an example scene that demonstrates the ability to pick up and drop items.
The samples contain a ItemController
that controls the movement of the items in the scene, moving them in squares as long as there are not picked up.
It also listens to the items dropItemPickUpSampleController
first adds a movement task and a pickup task for each item in the scene, as defined in the controller object.
Two swords will be picked up by the right hand, the first one gets attached to the hand socket, while the second one gets attached to the spine socket.
The third item is a ring that gets picked up and attached to the left hand.
The last item is a pill formed item, that will be picked up and held in the left hand.
After that the first item is dropped at a specified point.
The second item is dropped by calling the method that drops all items at a specific point.
Adaptive Gaze
To make an agent appear more life-like it can automatically look at objects and items in front of him, swerve between the objects, idle in between and pick up on sudden interest changes, like objects that start to move.
To make the agent look at objects that are about to be picked up the Adaptive
See adaptive gaze for more information.