bind keys to spring length?

Post your tutorials here.

bind keys to spring length?

Postby mrmegawarrior » Wed Aug 25, 2010 6:48 am

i have tried using some of the the tutorials on here but none of them work for me. can someone make a video tut. or a step by step one please?
mrmegawarrior
 
Posts: 80
Joined: Wed Aug 25, 2010 6:25 am

Re: bind keys to spring length?

Postby Nait » Wed Aug 25, 2010 10:03 am

OMG, TUTORIAL FORUM IS FOR POSTING TUTORIALS, NOT FOR ASKING!!!!!
:evil: :evil: :evil: GRRR!!!
I won't answer, in spite of I know answer :evil:
User avatar
Nait
 
Posts: 224
Joined: Fri Oct 30, 2009 1:56 am
Location: Eastern Russia, Vladivostok

Re: bind keys to spring length?

Postby Rideg » Wed Aug 25, 2010 3:13 pm

1. make two objects of your choice.
2. attach a spring between the two objects.
3. Open the console with the F11-button.
4. Type: Scene.my.spring = 1.
5. make a box above the ground and type in the onCollide: (e)=>{scene.my.spring = 2}
6. attach it to the backround and give the fixate a destruction key.
7. Open the script menu for the spring and type in the length section {scene.my.spring}
and press enter.
8. press the key and the box should fall down and hit the ground. When it does it will change the spring's length.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: bind keys to spring length?

Postby mrmegawarrior » Wed Aug 25, 2010 7:48 pm

but is there any way to bind keys to adjust the spring length
mrmegawarrior
 
Posts: 80
Joined: Wed Aug 25, 2010 6:25 am

Re: bind keys to spring length?

Postby Rideg » Wed Aug 25, 2010 9:42 pm

I think so but I'm not familliar with it. Try searching for it
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: bind keys to spring length?

Postby mrmegawarrior » Wed Aug 25, 2010 10:25 pm

i already have but the ones i have found havent been working for me
mrmegawarrior
 
Posts: 80
Joined: Wed Aug 25, 2010 6:25 am

Re: bind keys to spring length?

Postby Versieon » Thu Aug 26, 2010 3:28 am

No, there is no way to do this besides the way Rideg said, or some variation if it.
User avatar
Versieon
 
Posts: 375
Joined: Tue Sep 01, 2009 4:45 pm

Re: bind keys to spring length?

Postby mrmegawarrior » Thu Aug 26, 2010 3:57 am

ive seen other tutorials on this site that work for other people but i just cant get them working
mrmegawarrior
 
Posts: 80
Joined: Wed Aug 25, 2010 6:25 am

Re: bind keys to spring length?

Postby kilebantick » Mon Aug 30, 2010 1:41 am

There is, but it's not the traditional way of "Binding keys".
Create a scene.my.spring variable, set it to whatever value you want.
Place two lasers, facing the ground. In one laser, set the onlasercollide to (e)=>{scene.my.spring = scene.my.spring + 0.1}, and it's activation key to up.
On the other one, set the onlasercollide to (e)=>{scene.my.spring = scene.my.spring -0.1}, and it's activation key to down.

Now, create a spring, and change it's spring length to {scene.my.spring}
Press play, then press up, and down, and the spring should change length accordingly.
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: bind keys to spring length?

Postby mrmegawarrior » Mon Aug 30, 2010 5:49 am

thanks
mrmegawarrior
 
Posts: 80
Joined: Wed Aug 25, 2010 6:25 am

Re: bind keys to spring length?

Postby kilebantick » Wed Sep 01, 2010 6:12 am

No problem :)
Image
User avatar
kilebantick
 
Posts: 1267
Joined: Tue Sep 01, 2009 9:50 am

Re: bind keys to spring length?

Postby Dakta » Tue Aug 23, 2011 5:39 am

I hate to just come back to the forum after literally years of inactivity, but I'd like to point out that the lazer method is highly dependent on simulation speed and framerate, if my understanding of how lazers work is correct. A much more precise approach, and one which is much less subject to framerate fluctuations, is to use a spinning bar at the end of a lever.

1. Create a box 0.25m wide and 2.5m tall (Box A).
2. At the end of this box, attach a small (0.05m x 0.25m) box (Box B) via a spinning motor in the center.
3. Change the collision layer of this small box to B.
4. Place a key-press ("up") activated motor at the bottom of the tall box.
5. Create another box as tall as the tall box, but three or four times as wide, about three or four tall-box widths to the left of the tall box. Fixate this box to whatever you attached the tall box to.
6. Attach a spring to the two tall boxes (A & C) horizontally, set such that when the motor is not activated, Box A returns to an upright position. Accordingly, set up the Box A hinge so that when a key is pressed, the box is forced against the spring and into the other tall box.
7 Finally, fixate a small circle (called T) to the top of the biggest box (Box C). Set the collision layer to B. Place this box so that it is struck by Box B when is rotates.
8. Make sure you've gone to the console (Windows F11, Mac `/~ (tilde/backtic)) and "scene.my.spring = 0.5"

You see where this is going? When the key is pressed, the toggle box (A) moves and causes (B) to strike against (T) each time it rotates. As long as the key is held down, (B) will continue to strike (T). The rotational speed of (B) can be adjusted, depending on how fine control is needed.

The next step is to duplicate this contraption and apply scripting.

On the first copy (1), select the script menu of (T) and change the onCollide property to what kile said for the lazer ("(e)=>{scene.my.spring = scene.my.spring + 0.05}"). Do the same, but subtracting the increment ("(e)=>{scene.my.spring = scene.my.spring - 0.05}"), for the second (2) contraption. Make sure you change the motor controller on (2) to be something besides the controller for (1) (I suggest "down").

Hopefully now you have two spinning things attached to two bars, each which bands into a separate box when you press different keys. All that's left is to set scene.my.spring to what you want your initial spring length to be, and set the "length" property of that spring to "{scene.my.spring}" and you're done. You'll probably need to do some tweaking, and this IS a bit more complex, but it's more stable over framerate fluctuation than the lazer method.
.. ,__,_____
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial. Image
a Mammoth wrote:be boring and interesting.

Mystery wrote:If you were jailbreaker you shouldn't have when't up the 3.1.3
I didn't know you could go up 3.1.3! Thanks Mystery person!
User avatar
Dakta
 
Posts: 417
Joined: Sat Sep 12, 2009 4:36 pm


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests

cron