One controller
-
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! -
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 havegetVar("steer")
hope this helps!
/hpnisse
-
wow thx ur good
ow but i dont have an idea where to putif key("Up")==1 setVar("drive",1) elsif key("Down")==1 setVar("drive",-1) else setVar("drive",0) end
-
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
-
wow thx my friend xD
-
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.
-
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
-
what scripts did you use?
-
well i used the hpnisse's script, now im trying yours
-
both don't work backward
-
I've got both work correct both forward and backwards.
Download and look this model.
hpnisse vs hobbnob.skpI 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 -
i checked it... and yea it works, but in my model, i think that its something with wheels... check this:
Car -
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.skpTo 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
-
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
-
Good that your happy.
Have a nice summer! -
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... -
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. -
sooo.. now im gonna learn it a bit ;D
P.S.
The topic can be closed now
Advertisement