Simple Thruster Acceleration
-
I am not good yet with ruby scripts and I am trying to set an objects thruster to accelerate rather than just move at a constant speed. Is there a script I can enter into the Thruster Strength Box that would perform this?
-
It can be done. I can think of 3 different scripts that would be of use to you. One by wacov(the master of scripts), one by me and one by hobbnob. My one is easiest for you to edit i think and ive not got a copy of hobbnobs.
heres mine
` #acceleration script by 6677.
if frame>=0;setVar('accel',0.001) and setVar('decel',0.0001);end;setVar('control',righty);
if getVar('control')==0.5;setVar('speed',0.5);end;
if getVar('control')>0.5;setVar('speed',getVar('speed')+getVar('accel'));end;if getVar('speed')>=getVar('control') and getVar('control')>0.5;setVar('speed',getVar('control')-getVar('decel'));end;
if getVar('control')<0.5;setVar('speed',getVar('speed')-getVar('accel'));end;if getVar('speed')<=getVar('control') and getVar('control')<0.5;setVar('speed',getVar('control')+getVar('decel'));end;`
at the beggining where it says setVar('control',righty) you can change the righty to whatever you want to control it with. Place this script in the UI of any part of your model and put
getVar('speed')*whatever strenght you want
in the thruster strenght box -
My (shorthand) one is:
accel = 0.001 deccel = 0.001 control = righty thrust = 5000 @speed=0.5 if @speed==nil @speed-=deccel if @speed>control && @speed>0.5 @speed+=deccel if @speed<control && @speed<0.5 @speed+=accel if control>0.5 @speed-=accel if control<0.5 @speed+=deccel if control==0.5 && @speed<0.5 @speed-=deccel if control==0.5 && @speed>0.5 setVar("speed",(0.5-@speed)*thrust)
Essentially, you just need to stick the script in onTick (doesn't matter where), and getVar("speed") in the thruster field. At the top of the script, you can change the rate of acceleration and decceleration, the controller (leftx, lefty, rightx, etc...), and the thrust multiplier (how much thrust you want overall).
This script is shortened and simplified from my original version, slightly modified for use with a thruster. However, I'm really not sure you'll get the result you want...
Advertisement