sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Simple Thruster Acceleration

    Scheduled Pinned Locked Moved SketchyPhysics
    3 Posts 3 Posters 726 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      christcm
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • S Offline
        Sgt.A.Johnson
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • W Offline
          Wacov
          last edited by

          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...

          http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement