Rotating Lever

Tutorial collection, comprehensive listings on main site.

Rotating Lever

Postby Tutorial on Wed Nov 22, 2006 10:48 pm

category
General Half-Life 2/Entities

description
When pressed a lever will move from one position to another.

keywords
rotating, level, rotate.

Rotating Lever

Just like my last tutorial, this one will also be divided into steps, which will make it as easy as possible to both follow and understand it.
This time I will teach you how to create a leverhandle, which will rotate a bit when the player press a specific button. In the end you’ll have something like this:

Image

(The picture is from Half Life 2, Nova Prospect)

Step 1

I pressume you already have your area, so start with selecting the Entity Tool (Shift + E).
Place your info_player_start, or whatever your standard entity is, somewhere in your map by pressing the left mouse button. Now press Alt + Enter to bring up the Object Properties dialog box for that entity.
As Class, select prop_static and paste this:

models/props_wasteland/panel_leverbase001a.mdl

as the World Model, and then press the Apply button.

Image

You should now have something like this, apart from my fancy brushwork. :wink:

Image

As you can see the panel is leaning a bit. If you also want your panel to do that, simply right click on it and press Transform (Ctrl + M) and write –45 in the Y-textbox. Press the OK button, and you’re finished!

Image

Of course you don’t need to do this. If you want your panel in a 90 degree angle and up against a wall, that’s fine!

Now it’s time to add the leverhandle. Select the Entity Tool (Shift + E) and place a prop_dynamic entity. Paste this:

models/props_wasteland/panel_leverhandle001a.mdl

in the keyvalue called World Model and then press the Apply button.

Image


Step 2

We now have the basic things and it’s time to make the lever rotate.

Brows the toolsorgin texture, select the Block Tool (Shift + B) and make a brush with these dimensions:

Width: 2
Length: 8
Height: 2

(This acts as the axel for the entity.)

Now brows the toolsnodraw texture, select the Block Tool and make a brush with these dimensions.

Width: 4
Length: 8
Height: 4

Place the orgin brush, you made earlier, inside the nodraw brush you just made. It should look like this:

Image

Select both the nodraw brush and the orgin bursh and press Ctrl + T. This brings up a Object Properties dialog box. As Class select func_rotating then give your entity this name: lever01.
Select the keyvalue called Pitch Yaw Roll (Y Z X) and write this:

Image

Select the Max Rotation Speed keyvalue and write 30. To me that’s a perfect speed, but if you want it to rotate slower or faster, just write another number.
Set the Disable shadows keyvalue to Yes.
Select the Rotating sound WAV keyvalue and brows the sound you want the player to hear, IF you want any sound. I do, and I choosed this sound:

buttons/lever8.wav

Now press the Flags tab and make these changes:

Image

Now for a very important thing! Select your leverhandle, the prop_dynamic entity, and then select the keyvalue called Parent and write lever01.


Step 3

It’s now time to adjust the location of everything. Depending on how you want some of the things to be, my way might not be the correct way for you, nevertheless, the basic things will always be the same.

In my case, the leverhandle has this position:

Adjust your func_rotating entity, so it’s position is like this

In other words, at the bottom of the leverhandle.

Image


Step 4

We only need one more thing to make the lever rotate. Yes you guessed it, a button!

Brows the toolsnodraw texture and make a brush that covers the leverhandle. Press Ctrl + T and select func_button as Class. Set the Delay Before Reset keyvalue to –1.
Open the Outputs tab and make this output:

Image

If you want the lever to rotate further; change the delay value of the second output to a higher number. But be careful though! If you set the value too high, the lever will countine inside the panel, which will look very odd!

If you choose not to do the 5:th and optional step, you’re work are finished. Complie your map and see the result! Thank you for reading my tutorial! I hoped it improved the gameplay of your map!


Step 5 (Optional)


So, you’ve choosen to do the 5:th step also! Well, good for you! This will make your leverhandle even more jaw-dropping! Let’s begin!

Select the Entity Tool (Shift + E) and place a env_sprite entity, adjust the location, so it looks like this:

Image

Give the env_sprite this name: env_sprite01 and make these changes to the keyvalues:

Render Mode: World Space Glow
FX Color (R G B): 255 0 0
Scale: 0.20
Size of Glow Proxy Geometry: 2.0

Press the Flags tab and check the Start on checkbox.
Create a env_spark entity and give it this name: env_spark01. Place it like the picture is showing:

Image

Adjust the location of the button you created earlier and make these new outputs:

Image

So when the player press the invisible button, the leverhandle starts to rotate. At the same time the env_sprite turns off. After two seconds, the leverhandle stops and the env_sprite is again visible, but now in a green color and at the same time, some sparks fly away, indicating that the power is on.

That concludes the tutorial and thank you for reading it!

There’s a lot more you can do, I hope I’ve stimulated your imagination


PS: Yes, that final line above is from aKilling Source mapping… but the tutorial, is my own!!

Tranced_Psycho
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Postby Kodox on Fri Feb 09, 2007 12:14 pm

Haven't tried this yet but the tutorial is nice and simple. Great job.
User avatar
Kodox
May Contain Skills
May Contain Skills
 
Joined: Fri Jul 21, 2006 7:54 pm
Location: Ohio

Postby zombie@computer on Fri Feb 09, 2007 2:39 pm

You do know you can use a func_rot_button instead of a func_rotating and a func_button? The func_rot_button is a normal button, yet it rotates like a lever or wheel
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Rotating Lever

Postby musterfox on Sat Sep 20, 2008 1:03 pm

Thanks for the tut. I created a lever and it works fine. However i have some questions about a variation for this lever.

What if i want that the lever

a) can be "used" repeatedly
b) must return back to its original position after a delay of say 2 seconds after fully down?

I cant seem to get this to work. Heres what i tried:

MyOutput ---TargetEntity--- TargetInput---Delay---OnlyOnce
OnPressed---Lever01---------Start----------0----------No
OnPressed---Lever01---------Stop----------2.5--------No
OnPressed---Lever01---------Reverse------4.5----------No

The problem with the above is -

1) the lever does not come back automatically. I have to press "use" to get it to return back to its original position.

then i tried this:
MyOutput---- TargetEntity---TargetInput--------Delay-- OnlyOnce
OnPressed----Lever01---------Start----------------0---------No
OnPressed----Lever01---------Stop----------------2.5-------No
OnPressed----Lever01---------StartBackward-----4.5-------No
OnPressed----Lever01---------StopAtStartPos----4.6-------No

The above works fine if used ONCE. Any attempt to use the lever a second time results in the lever using the "startbackward" input (i assume) as it rotates backward and right through the object instead of rotating forward in the correct direction. Isnt there a command to "loop" the output in some way so as to force it back to instruction 01 after instruction 04?

What am i doing wrong?
TIA
musterfox
Regular
Regular
 
Joined: Fri Sep 05, 2008 12:22 pm

Re: Rotating Lever

Postby xoqolatl on Mon Oct 06, 2008 11:16 am

You can also use func_door instead of a button. It will return automatically, and if your lever is a brush, one entity will be enough (instead of three entities suggested in the original tutorial).
User avatar
xoqolatl
May Contain Skills
May Contain Skills
 
Joined: Mon Nov 13, 2006 9:11 pm
Location: Warsaw / Poland

Return to Tutorials

Who is online

Users browsing this forum: No registered users