Oscillator script
-
Seems I'm making one for everything now. This may seemed over-engineered, but the crucial thing is that this is CONTROLLABLE! I've made it as user-friendly as I can, so to change the cycle rate, just change the local variable 'rate' at the top of the script. To make it controllable, which is, ultimately, the point, you can use joystick, slider, button or key entry to change 'rate'. There's also room for expansion, using your own script to control the rate. The output of the script is a variable called "pos", and, if the line breaks are removed, this should work straight from a joint's controller box. Could well be useful in the upcoming SP challenge, so, here it is:
rate=50; if frame==0; setVar("pos",0.5); setVar("direct",1); end; if getVar("pos")>1.0; setVar("direct",0); elsif getVar("pos")<0.0; setVar("direct",1); end; if getVar("direct")==1; getSetVar("pos",getVar("pos")+(1.0/rate)); else; getSetVar("pos",getVar("pos")-(1.0/rate)); end;
This wasn't hard to write, so I don't really want or expect any credit. Use and spread freely!
-
Nice, but I won't be needing it; my (probable) entry uses keyboard input only, so I have it working fine.
...I might as well throw in a small contribution from my model:if key("space")==1 then setVar("timer",frame+3);end; if frame<=getVar("timer") and key("space")==0 then setVar("jump",1);else setVar("jump",0);end;
that up there is a jump code. When you let go of the spacebar, jump will be set to 1 for 3 frames. A jump code that did that when space was pressed was a little too long and tricky to write, so I made this one. Having it jump after the key is let go also allows for a "wind up" while it's pressed
oh, question for wacov: why do you use semicolons all the time, instead of then and and? I find using words makes it easier for others (and myself on occasion) to understand with a quick glimpse.
-
..speaking of quick glimpses, here's one for you Not my most recent version, but should give you an idea.
[flash=480,300:2v6x2t0v]http://content.screencast.com/users/sketchupBTM/folders/Jing/media/57eec274-eaa0-44be-a571-1adbe863b1c7/jingswfplayer.swf[/flash:2v6x2t0v]...Can a moderator fix that flash ? I put in the right adress from the embeded src, I THINK, but...
...(sigh)... here's the link. http://www.screencast.com/t/ZyU2omCfC2A
-
Thats an amazing model BTM! I cant wait until its finished.
I dont know why the flash isnt working. But I'll see if I can fix it....
-
Thats a good oscillator script. But I should point out that it isnt exactly the same as the built in one. That one is based of a sine wave. So the object slows down smoothly at either end of the period. But for most applications this is probably just as good.
I am going to try to make it so you can package up useful scripts like this and reuse them easier.
-
I use semi-colons because it's slightly shorter to write, and it's (I think) good practice to use them at the end of every line. Also means you can take out the line breaks without a problem.
BTM, your link doesn't work for me?
-
The link works fine for me. I don't know if you need flash player installed though, so yeah...
-
Ok, works now. That's awesome! Well done
-
... Something else that may be included...
[flash=320,200:17g34xur]http://content.screencast.com/users/sketchupBTM/folders/Jing/media/40aec8da-d5f1-4f37-9730-b59356b28a68/jingswfplayer.swf[/flash:17g34xur]
Again with the broken flash, sorry,
http://www.screencast.com/t/iy4gqmsMbNWSo far I've been just messing around with ideas for my character (The robot may just be temporary; it's pretty basic and square),but here are some of it's "stats" if you will.
...I think I might improve the running speed, but it messes up the leg/ arm movement a bit too much
I've also been thinking about adding "kick" to the list, but the codes seem complex enough as it is
Advertisement