SketchyPhysics - New Grip System for Cars ! !
-
Ever built a sketchyphysics car? And theres no grip on the ground? Well never fear, 'cos MrDailyBlah is here....(!) (!)
I recently fiddled around with the raytest function, and i thought i could incorporate it in to the sim...
A floor in sketchyphysics is perfectly smooth...it doesnt create friction like a normal surface would. To create more grip, the most obvious solution is to apply negative thrust to the car's body or suspension, but this collapsed the wheel hinges.
I tried to use magnetism as a solution, and i found that if i could use the raytest function, i could find a point under each wheel on the floor, to each of which i can teleport a magnetic object, attracting the wheels to the floor and creating grip without collapsing the car...
That was it in a nutshell... here's the code i used -
# paste the following into the floor onstart{ # a way to simplify Sketchup.active_model.raytest def newRay(p,d) ray=Sketchup.active_model.raytest(p,d) return ray end } # then i copied the following script 2 each wheel ontick{ t=[0,0,-1] ray1=newRay(position,t) ray2=newRay(ray1[0],t) s=@simulation.findBody("sphere...") # the magnetic object; theres a unique one 4 each wheel s.teleport ray2[0] if (ray2!=nil) and (s!=nil) }
P.S. make sure u know how it works befor u copy it... ( )
-
This is great, nice feature, thanks
-
What a nice Holiday present. Can't wait to try it...(once I understand it (:)).
-
Where did you put this script?
Don -
@don east said:
Where did you put this script?
Donu need to put it in the "scripted" section of the Sketchyphysics UI (neither the "ontick" or "ontouch" section would work...)
-
Hehe not a bad idea, but you could just have put push([0,0,-1]) in the ontick field of the wheel, does exactly the same thing
(little extra note, if you want to have the vehicle turn on it's side/upside down and still have it work, then encase your steering block around the drive joint (either hinge or motor dependign on your preference) and they won't collapse)
-
@hobbnob said:
Hehe not a bad idea, but you could just have put push([0,0,-1]) in the ontick field of the wheel, does exactly the same thing
(little extra note, if you want to have the vehicle turn on it's side/upside down and still have it work, then encase your steering block around the drive joint (either hinge or motor dependign on your preference) and they won't collapse)
uh..well.. push([0,0,-1]) creates a violent vibration in the wheels.. so its not that simple..
p.s. i looked in ControllerCommands.rb and found the push()method is the same as $sketchyPhysicsToolInstance.pushBody(), which creates the vibration i talked about...
-
I haven't had that problem in the 4 years I've been using sketchyphysics, you sure you've got your wheels geom and ontick interval set up correctly?
-
@hobbnob said:
I haven't had that problem in the 4 years I've been using sketchyphysics, you sure you've got your wheels geom and ontick interval set up correctly?
sure as pants man..
-
Yeah I have the same issue with Hobbnobbs micro script - I am building a walking machine - the fluctuation which is somehow included in hobbnobs micro script causes my machine do hover and float around slowly.
When I implement MrDailyBlah's I get the kind of traction for my machine's feet that I was looking for. Can increase traction by changing the value'-1' in the part of the script that goes in the wheel to '-2'. Nice work
I've got no idea where the vibration is coming from - funnily enough, the other two variables marked '0' in hobbnobs script control push in a certain direction. You can make your machine/vehicles hover in certain directions using these variables.
-
I've added a little complexity that is causing this script to crash SP when I try to run it.
As far as I can tell it has something to do with the raytest function - potentailly related to the issue described on this thread: http://forums.sketchucation.com/viewtopic.php?f=180&t=30558
I have tested it in SU7 as well but am getting the same issue - basically the model explodes, the POV zooms way out and all I can find left in the model is a bunch of endpoints (like on the end of a tapemeasure guide......can anyone shed some light?
Ash
-
@ashscott said:
I've added a little complexity that is causing this script to crash SP when I try to run it.
As far as I can tell it has something to do with the raytest function - potentailly related to the issue described on this thread: http://forums.sketchucation.com/viewtopic.php?f=180&t=30558
I have tested it in SU7 as well but am getting the same issue - basically the model explodes, the POV zooms way out and all I can find left in the model is a bunch of endpoints (like on the end of a tapemeasure guide......can anyone shed some light?
Ash
that's right sir...
i used raytest to find the point where the wheels touch the floor, then i teleport magnets to them to attract the wheels... -
But Raytest has a tendency to cause SU to flip out - know of a workaround or why I am having the symptoms described?
-
@ashscott said:
But Raytest has a tendency to cause SU to flip out - know of a workaround or why I am having the symptoms described?
uh... nooo...
u'd better consult pros like Wacov.. -
So you're not getting the issues I described two posts ago.....?
I seem to get it no matter how I run it (apparently the raytest issue was clashing with SU8 but I can't even get it working right in SU7)
-
@ashscott said:
So you're not getting the issues I described two posts ago.....?
I seem to get it no matter how I run it (apparently the raytest issue was clashing with SU8 but I can't even get it working right in SU7)
try reinstalling sketchup or SP or sumthing ...
Advertisement