• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Acceleration script (working)

Scheduled Pinned Locked Moved SketchyPhysics
7 Posts 5 Posters 1.3k Views 5 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.
  • W Offline
    Wacov
    last edited by Wacov 22 Apr 2009, 13:32

    I decided to make this when I realised my new vehicle didn't feel heavy enough; I wanted it to be fast, but I didn't want instant acceleration and decceleration. This script deals with both problems, and you can adjust the acceleration and braking to your needs by changing the local variables at the top... well, here it is:

    #Acceleration Script by Wacov
    
    accel=0.005
    deccel=0.015
    
    if frame==0; then;
    setVar("speed",0.5);
    
    end;
    
    
    if getVar("speed")>joyRY and getVar("speed")>0.5;
    setVar("speed",getVar("speed")-deccel);
    
    elsif getVar("speed")<joyRY and getVar("speed")<0.5;
    setVar("speed",getVar("speed")+deccel);
    
    end;
    
    
    if joyRY>0.5; then;
    setVar("speed",getVar("speed")+accel);
    
    end;
    
    
    if joyRY<0.5; then;
    setVar("speed",getVar("speed")-accel);
    
    end;
    
    
    if joyRY==0.5 and getVar("speed")<0.5;
    setVar("speed",getVar("speed")+deccel);
    
    elsif joyRY==0.5 and getVar("speed")>0.5;
    setVar("speed",getVar("speed")-deccel);
    
    end;
    

    It will not accelerate beyond the input, so the overall speed is controllable. To change the control, change all the 'joyRY's to whatever you want.

    To use, place in any onTick field. For a vehicle's motors, use:

    0.5-getVar("speed")
    

    In the motor's controler field. Hope this is useful!

    Have at look at: http://sketchup.google.com/3dwarehouse/details?mid=9047719249a2da26cd8ad826e9017b8&prevstart=0 To see it at work.

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

    1 Reply Last reply Reply Quote 0
    • P Offline
      phy
      last edited by 22 Apr 2009, 14:53

      Good, only thing is that when you hit something it doesn't slow you down. But it's very good.

      Tableau de comparaison de Staxyn s'agit d'un mГ©dicament uniquement sur ordonnance.

      1 Reply Last reply Reply Quote 0
      • M Offline
        MrPlanet
        last edited by 22 Apr 2009, 18:32

        So, you can control how fast it goes? 😄

        I reject your reality and substitute my own.

        1 Reply Last reply Reply Quote 0
        • W Offline
          Wacov
          last edited by 22 Apr 2009, 19:15

          😄 Nah, how fast it accelerates. Normal cars don't go from 0-120 in half a second; the script fixes that

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

          1 Reply Last reply Reply Quote 0
          • M Offline
            Mitchieboy
            last edited by 29 Aug 2009, 22:20

            I don't fully get it....

            1 Reply Last reply Reply Quote 0
            • S Offline
              shareck
              last edited by 5 Sept 2009, 20:43

              Very good! But please tell me how did you achieve such a good grip??

              1 Reply Last reply Reply Quote 0
              • W Offline
                Wacov
                last edited by 5 Sept 2009, 20:52

                My method is quite complicated, but it revolves around a thruster pinning the car to the ground. Try putting -5000 in the thruster setting for the car's body (you might get some odd results, though)

                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