SketchyPhysics Keyboard Controls
-
Hi all,
discussion on sketchyphysics sure seems to have cooled off since I was last in this part of the forum 2 years ago - thats a shame, over the last few days I have been using SP to model a proposed walking machine and it really is an extraordinary plugin.
I have a couple of questions for you folks that are more familiar with SP and Ruby:
- Using (rightx) how do I get servo to sit in a position and stay there without spring loading back to its midway point? I am lifting a leg with the servo, pressing one arrow raises the leg and pushing the opposing arrow lowers the leg but if I release the arrow at any time the leg springs back to the middle position. How can I set things up so the leg maintains it's position when I release the arrow key? Currently the controller says this:
slider('A2_Tilt',0)+(rightx)
- Is there a way to apply the same set of keys for certain objects and toggle between them, for example my walking machine has four legs. I can use (rightx) and (righty) to lift and place one leg - is there a way that I can set up a toggle function to apply those keys to each leg in real time so I can move each one individually? IE press spacebar so that the (rightx) and (righty) functions apply to the next leg on the machine?
Any help is much appreciated - I love the plugin and would pay for it if it would encourage Cphillips and co in their endeavours (you can't work for free)
Thanks
Ash
-
Answers to these questions:
- Use a motor not a servo
- Toggling between keys looks something like this:
if key("m")==1 @B1_Tilt=(righty) and @B1_Twist=(0.5-rightx) and @B1_Ext=key("b") elsif key("m")==0 and key("n")==0 @stick=0.5-(righty)
If I hold down ("m") the joystick controls a different set of functions than if I hold down ("n"). I also have another set of functions for the joystick if no key is pressed so I have three joysticks in one.
"m" and "n" have been assigned to my second joystick using the software 'joytokey' which I highly recommend. It allows you to set functions to the keyboard but then run them through a second joystick to your primary joystick.
Thus, I am running my sketchyphysicks sim with a logitech attack3 joystick in each hand.
It is an industrial simulation and I haven't seen anything else like it done online. I can't share more because its under NDA but if anyone wants help with something like this then let me know.
Ash
-
There is a much better answer than using a motor to place a joint where you want it - you need to use a servo and a little ruby script
Step1: place your servo within the group you want to move and attach it to a base group
Step2: select the servo and open the sketchyphysics UI
Step3: within the UI apply the following settings
[list=]min:0
max:1
accel:4000
damp:1000
controller:@servo1 (you can actually call it anything starting with @
[/list]
Step4: Select the base of your model and open the sketchyphysics UI
Step5: place the following rubyscript in there:if frame<1.00 @servo1=0.00 end # this allows servo to incrementally increase based on joystick input (righty) you can change it to any of the joystick axes @servo1+=(0.5-righty) # this sets range of movement for the servo as it is not set in the servo's UI if @servo1>45;@servo1=45;end if @servo1<-45;@servo1=-45;end
It took me a long time to work this out (reverse engineering another model) so I am more than happy to help anyone out with it if these instructions are too hard to follow.
I believe this is a very powerful function in sketchyphysics and I have only seen it in one model in the 3DWH
-
You should just put hinge to limit movement, and motor to move. Put high damp and high speed on motor to make it stand still in position. That is how I make my models, which you can see on my site: http://forsa07.wix.com/dl-design#!design/cc9
Advertisement