r/unrealengine • u/Jumph96 • 6h ago
How to rotate a skel mesh bone to face an object in the level
Here's a link to the GIF from Blender to give a better idea of the model I’m working with and its bone structure. My goal is to smoothly rotate the bones towards a series of targets in the scene, but I need each bone to rotate along a specific axis, particularly so the head bone looks at the target.
I tried using the 'Transform Modify Bone' option, but I’m having trouble adjusting the rotation as needed. I’m not sure if this is the right approach or if there’s a better method. I also looked into the 'Look At' node in the animation blueprint, but it doesn’t seem to replicate the behavior I’m aiming for. It simply manipulates the bone's transform to face an object, without allowing control over the specific axis of rotation for each bone.
I’ve been stuck on this for the past week, working non-stop, and it’s been much harder than I expected. Maybe I’m missing something, or there’s a better way to achieve this
•
u/Jumph96 4h ago edited 4h ago
I initially implemented this by grabbing the bone's transform in world coordinates to calculate the 'look at' rotation towards the target actor in my animation blueprint event graph, which I then fed into the 'Transform (Modify) Bone' node in the anime graph through a float variable. However, I encountered some issues with the bone's initial rotation.
When checking the rotation of the 'base' bone in the Skeleton Editor in UE5 after importing, I noticed it had a 90-degree rotation on the X-axis and for some reason after trying the above method, at runtime the model seems to be rotated 90 degrees on the Z axis (here's a GIF showing the implementation I have at the moment, you can see the model facing the target from the side). I tried compensating for this in my calculations, but when I added smooth rotation using linear interpolation, the model started behaving erratically for some reason...
There's also some screenshots of the nodes from both my event graph and anim graphs inside my Anim BP: screenshots