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

    One controller

    Scheduled Pinned Locked Moved SketchyPhysics
    21 Posts 3 Posters 2.0k 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.
    • V Offline
      Vtec234
      last edited by

      ok but how to make that up is forward and down is backward?

      @EDIT
      Because I made a car and when I press "up" the car doesn't move because wheels turn in other directions!

      1 Reply Last reply Reply Quote 0
      • H Offline
        hpnisse
        last edited by

        Hello!

        
        if key("Up")==1
          setVar("drive",1)
        elsif key("Down")==1
          setVar("drive",-1)
        else
          setVar("drive",0)
        end
        
        

        Put this code somewhere in the model, and on the motors (that will let the car go forward/backwards), put this in controller field:

        getVar("drive")
        

        This should let you control the car with up/down arrows. (when you don't push either up/down the motors will stops)
        And if you want to steer your car you can use the same code with some changes.

        
        if key("Left")==1
          setVar("steer",1)
        elsif key("Right")==1
          setVar("steer",-1)
        else
          setVar("steer",0)
        end
        
        

        And in the servo joints, there shall be only one of the field "Max"/"Min" with numbers (degree of rotation of the wheels), and the other of these two fields will be empty (set to zero "0").
        And the controller field in the servo will have

        getVar("steer")
        

        hope this helps!

        /hpnisse

        ` /hpnisse`
        ` Windows 7 U -Sketchup 8 -SketchyPhysics 3.2-Dec2 - from Sweden`

        1 Reply Last reply Reply Quote 0
        • V Offline
          Vtec234
          last edited by

          wow thx ur good πŸ˜„
          ow but i dont have an idea where to put

          if key("Up")==1
            setVar("drive",1)
          elsif key("Down")==1
            setVar("drive",-1)
          else
            setVar("drive",0)
          end
          

          😞

          1 Reply Last reply Reply Quote 0
          • H Offline
            hpnisse
            last edited by

            Somewhere in the model, just create a static box or something and put this (and the steering script) in the "ontick" field!

            Then it will work πŸ˜„

            ` /hpnisse`
            ` Windows 7 U -Sketchup 8 -SketchyPhysics 3.2-Dec2 - from Sweden`

            1 Reply Last reply Reply Quote 0
            • V Offline
              Vtec234
              last edited by

              wow thx my friend xD

              1 Reply Last reply Reply Quote 0
              • H Offline
                hobbnob
                last edited by

                same thing as hpinsse's script, just all in one place:

                setVar("drive",-(0.5-righty))
                

                both do exactly the same thing, just that's shorter.

                My WIP Thread:Here

                1 Reply Last reply Reply Quote 0
                • V Offline
                  Vtec234
                  last edited by

                  umm yea now i made a car (without steering, just forward and backward), but it doesn't move backward, only forward O.o A standard question: what is going on? xD

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    hobbnob
                    last edited by

                    what scripts did you use?

                    My WIP Thread:Here

                    1 Reply Last reply Reply Quote 0
                    • V Offline
                      Vtec234
                      last edited by

                      well i used the hpnisse's script, now im trying yours

                      1 Reply Last reply Reply Quote 0
                      • V Offline
                        Vtec234
                        last edited by

                        both don't work backward πŸ˜•

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          hpnisse
                          last edited by

                          I've got both work correct both forward and backwards.

                          Download and look this model.
                          hpnisse vs hobbnob.skp

                          I don't know what you did but here I got both working with the up/down arrowkeys at same time.

                          Hope this helps understanding! πŸ˜„
                          /hpnisse

                          ` /hpnisse`
                          ` Windows 7 U -Sketchup 8 -SketchyPhysics 3.2-Dec2 - from Sweden`

                          1 Reply Last reply Reply Quote 0
                          • V Offline
                            Vtec234
                            last edited by

                            i checked it... and yea it works, but in my model, i think that its something with wheels... check this:
                            Car

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              hpnisse
                              last edited by

                              You use servo as motor, I changed it so all servo is the "motor" joint insted. and it work perfect. πŸ˜‰
                              Then I use my script and changed some stuffs so it would be easy to change the speed.
                              SamochΓ³d.skp

                              To change the speed of the wheels then change the number "3" in the "Speed" box.

                              
                              if frame==1
                              setVar("speed",3)
                              end
                              
                              

                              then it will work fine.

                              /hpnisse

                              ` /hpnisse`
                              ` Windows 7 U -Sketchup 8 -SketchyPhysics 3.2-Dec2 - from Sweden`

                              1 Reply Last reply Reply Quote 0
                              • V Offline
                                Vtec234
                                last edited by

                                ow... thanks i didn't think about the motor joint πŸ˜„

                                thank you guys for all the help - this forum users are really intelligent - the car works perfecto πŸ˜‰

                                1 Reply Last reply Reply Quote 0
                                • H Offline
                                  hpnisse
                                  last edited by

                                  Good that your happy. πŸ˜„
                                  Have a nice summer!

                                  ` /hpnisse`
                                  ` Windows 7 U -Sketchup 8 -SketchyPhysics 3.2-Dec2 - from Sweden`

                                  1 Reply Last reply Reply Quote 0
                                  • V Offline
                                    Vtec234
                                    last edited by

                                    Thanks and you too ;D Ow, but an other question - what scripting language is it written in?

                                    @EDIT
                                    Because some of those Sketchy things are in Ruby.. but i think SketchyPhysics doesn't use it...

                                    1 Reply Last reply Reply Quote 0
                                    • H Offline
                                      hpnisse
                                      last edited by

                                      It should be in ruby I think.
                                      http://sketchyphysics.wikia.com/wiki/Ruby
                                      It says that Ruby is used to control SketchupPhysics so I think SP would be written in that script.

                                      ` /hpnisse`
                                      ` Windows 7 U -Sketchup 8 -SketchyPhysics 3.2-Dec2 - from Sweden`

                                      1 Reply Last reply Reply Quote 0
                                      • V Offline
                                        Vtec234
                                        last edited by

                                        sooo.. now im gonna learn it a bit ;D
                                        P.S.
                                        The topic can be closed now

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

                                        Advertisement