- Home /
How to stop animation bones from rotating around wrong axes via script
I've been trying to make a turret script, that can animate a tank turret traversing horizontally, and pitching its gun up and down. I've made a script that works perfectly for nested gameobjects. But as soon as I try to apply the script to an animation rig, the bones start rotating in undesirable ways.
I created my rig in Blender, and am aware that this tends to lead to weird behaviour due to the differences between how Blender and Unity handle coordinates. I have used this addon to fix my model's rotations, and while the addon appears to have worked, the turret bones are still rotating around the wrong axes.
What can I do to make my model turret work properly?
Here's the script I'm using: https://pastebin.com/raw/4ZGZtWHY
The turret script is working near-perfectly, by the by. It's finding the target just fine, and rotating the bones to stay focused on it. It's just that the bones are rotating around the wrong axes to get there, which is what I want to fix.
Here's some images showing what's happening:
In editor, pre-game:
In-game, mid-rotation: