Hello @Crixoule , thank you for your question!
You mention the animation is working fine in RCP, which sounds like it was imported succesfully! Were you able to use AnimationLibraryComponent
to preview it in RCP? For your use case specifically, I recommend taking a look at our BOT-anist sample, spefically how the backpack and head are attached to the main body of the robot.
In RealityKit, the skeleton joint positions are not separate entities with transform components, as you might expect. This means you don't interact with them by placing other Entities as descendants of the skeleton joints. Instead, to get the position of a joint for the purpose of attaching another Entity to it, you calculate its transform by multiplying a chain of joint transforms together each frame.
There are a few steps to this, first you will need to get the indices for the chain of joints starting from the root joint that connect to your "head" or "backpack" or "arm_cannon" or whatever joint you're looking for. In BOT-anist, see the function getJointHierarchy
in RobotCharacter.swift
for a code implementation. Then, you will need to set the pin on the skeleton, which occurs on lines 92 and 93 in that same file, which will return an entity with a position you can use as an offset later. Finally, the code for setting the position each frame exists in JointPinSystem.swift
in the function named pinEntity
. This contains the relevant code for multiplying your chain of joint transforms together and setting the position of the pinned entity.
Let me know if that answers your question! I highly recommend sending us any feedback you have about animation APIs in RealityKit using Feedback Assistant. Thank you!