Wheel rotation accelerator
as usual I have a problem with my script...
The goal is to develop a scripted modifier for a car rig that allows to set wheel speed.
The car will be on a path, so in my idea we should have 4 buttons, one for regular speed based on car movement along the spline, one for reverse gear, one for stopping wheels and one for delete created keys and set value to zero.
We also need a slider to control wheels speed during start, drift and stop.
Thanks to this thread:
I get my slider to work, but if I decrease speed the wheel rotate backwards (even if value is >0).
I also found the way to get wheel rotation speed based on wheel movement, using a script controller for rotation (found here http://www.youtube.com/watch?v=aXudtFIga6o):
Path = path -- spline used as a path constraint Percent = $car.pos.controller.Percent -- car % on path Radius = -- wheel radius SplineLenght = CurveLenght Path (Percent/100)*SplineLenght/Radius
but now I have to implement it in my script, and no idea how to do this :(
My code until now is:
plugin modifier WheelSpin name:"WheelSpin" classID:#(0x133067, 0x54412) version:1 ( parameters main rollout:RUOTE ( fws_sli type: #float ui:fws_sli ) rollout RUOTE "RUOTE" ( slider fws_sli "FrontWheels" offset:[0,10] width:140 range:[-30,30,0] type:#float orient:#horizontal ticks:10 animatable:true button fws_ground_retro "GrSpd R" offset:[-41,-5] width:60 height:15 button fws_zero "0" offset:[-1,-20] width:18 height:15 button fws_ground "GrSpd" offset:[37,-20] width:60 height:15 button fws_DK "Delete All Keys" offset:[-2,-5] width:138 height:15 on fws_sli buttondown do ( animButtonState = True ) on fws_sli buttonup do ( animButtonState = False ) on fws_DK pressed do ( deletekeys $wheel.modifiers[#WheelSpin].fws_sli.controller ) ) )
The slider works, the delete keys button works too.
This one should set slider value to zero too, but no way to make it work...
on fws_DK pressed do (createKey $wheel.modifiers[#WheelSpin].fws_sli.controller = 0)
So any idea on how to make this script to work?
PS. I attach a simple file setted up to test the script