MaxT2K
01-30-2009, 10:39 AM
Hi everyone,
I've recently started my own series of animations and have a character that rides a monocycle through some obstacles and came up with the seemingly brilliant idea of writing a Mel code that would automatically turn the wheel as the monocycle move.
I wrote this script pretty quickly and based the original means of measurement on monocycles controller's Z translate. I knew that this would be dependent on world space so the program would not work in all directions but it at least moved realistically back and forth.
Here is the code... (Note that I added new attributes 'WheelStop' to the control and 'PreWheelRotate1' (which rotates the wheel's begining position) and 'WheelSpeed' (Set at 37) to the wheel.)
------
float $oldtranslate;
float $Wprerotate;
if (MonocycleCtrl1.WheelStop < 1) {
Wheel1.rotateX+=((MonocycleCtrl1.translateZ-$oldtranslate)*Wheel1.WheelSpeed)+(Wheel1.PreWheelRotate1-$Wprerotate);
};
$oldtranslate=MonocycleCtrl1.translateZ;
$Wprerotate=Wheel1.PreWheelRotate1;
------
The trouble is that if you turn the monocycle 90 degrees the wheel doesn't rotate at all when you move it. I had hoped to find a way after this to get a consistant messurement such as finding a node for local translate, rotating the translates or even a combination of Parenting and Constraining to make translate Z follow.
You can put the object in a group and turn that at the start but if you want to turn it again it slides the wrong way.
I've looked everywhere to find some answer but to no success so if you can help it would be very much appreciated.
Thank you.
Max
I've recently started my own series of animations and have a character that rides a monocycle through some obstacles and came up with the seemingly brilliant idea of writing a Mel code that would automatically turn the wheel as the monocycle move.
I wrote this script pretty quickly and based the original means of measurement on monocycles controller's Z translate. I knew that this would be dependent on world space so the program would not work in all directions but it at least moved realistically back and forth.
Here is the code... (Note that I added new attributes 'WheelStop' to the control and 'PreWheelRotate1' (which rotates the wheel's begining position) and 'WheelSpeed' (Set at 37) to the wheel.)
------
float $oldtranslate;
float $Wprerotate;
if (MonocycleCtrl1.WheelStop < 1) {
Wheel1.rotateX+=((MonocycleCtrl1.translateZ-$oldtranslate)*Wheel1.WheelSpeed)+(Wheel1.PreWheelRotate1-$Wprerotate);
};
$oldtranslate=MonocycleCtrl1.translateZ;
$Wprerotate=Wheel1.PreWheelRotate1;
------
The trouble is that if you turn the monocycle 90 degrees the wheel doesn't rotate at all when you move it. I had hoped to find a way after this to get a consistant messurement such as finding a node for local translate, rotating the translates or even a combination of Parenting and Constraining to make translate Z follow.
You can put the object in a group and turn that at the start but if you want to turn it again it slides the wrong way.
I've looked everywhere to find some answer but to no success so if you can help it would be very much appreciated.
Thank you.
Max
