Create traffic lights: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(I translate. sorry for baD english! ^-^)
 
(formatting)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{otherlang2
{{languageBar}}
|ru=Create traffic lights:ru
}}


= Traffic lights :) outputs and inputs=
The {{hl2|4}} assets already provide a model of a signal light, this tutorial will explain how a dynamic traffic light can be set up using [[Inputs and Outputs|I/O]].


I think that you see in Half-Life 2 model of traffic lights? о_0 But it's simple model... Here I tell you how make a realy working lights.
==Required entities==


==What we need to make? о_0==
* One {{ent|prop_dynamic}} with the following keyvalues:


* Model <code>props_c17\Traffic_Light001a.mdl</code> <code><b>prop_dynamic</b></code>
{| class="wikitable"
 
|-
* color lights: <code>point_spotlight</code>s on each lights =).
! Keyvalue !! Value
 
|-
* model properties:
| World Model || {{path|icon=file|props_c17\traffic_light001a|mdl}}
|-
| Disable Shadows || Yes
|-
| Collide with world || Not solid
|}
{{note|"Not solid" is necessary when you want to place the lights inside the model or very close to it}}


:'''Disable Shadows=Yes'''
* Three {{ent|point_spotlight|alt=point_spotlights}} placed at roughly the right position near the model.


:'''Collide with world=Not solid''' (if you don't do this, light does not appear in game).  
* One {{ent|logic_auto}}.


* one <code>logic_auto</code>, two <code>logic_relay</code>.
* Two {{ent|logic_relay|alt=logic_relays}}.




==I/O setup==
[[File:CBETOFOPkpacHbIu.jpg|240px|thumb|right]]
[[File:CBETOFOPkpacHbIu.jpg|240px|thumb|right]]
[[File:CBETOFOPredYellow.jpg|240px|thumb|right]]
[[File:CBETOFOPgreen.jpg|240px|thumb|right]]
[[File:CBETOFOPyellow.jpg|240px|thumb|right]]


=='''In details...'''==


'''T'''ime. ''Traffic lights'' lights for different time. Because road can be wide and big, can be small. If road wide then ''lights'' lights longer.
The input and output logic will define how long each light will be visible, this example will use the following durations:


Red and Green - 30 seconds
* Red and green - 30 seconds


yellow - 3 sec
* Yellow - 3 seconds


==outputs!==
===Entity names===
[[File:CBETOFOPredYellow.jpg|240px|thumb|right]]


1. give ''targetname''s for each of 3 point_spotlight with names: "greenLight" "redLight" "YellowLight". 1 logic_relay call traffLightRelay1, 2 - traffLightRelay2.
The {{mono|[[targetname]]}} keyvalue defines the name of the entities, the three point_spotlights should use the following names respectively: "{{mono|greenLight}}" "{{mono|redLight}}" "{{mono|yellowLight}}". The first logic_relay will be named "{{mono|traffLightRelay1}}" and the second one "{{mono|traffLightRelay2}}".


2. select logic_auto
===Outputs===
 
[[File:CBETOFOPgreen.jpg|240px|thumb|right]]
3. in outputs
[[File:CBETOFOPyellow.jpg|240px|thumb|right]]
The logic_auto requires the following output:


{| {{OutputsTable}}
{| {{OutputsTable}}
| [[Image:Io11.png]] || OnMapSpawn || traffLightRelay1 || Trigger || &nbsp; || 0.00 || Yes || '''Turn on this! :D'''
| [[File:Io11.png]] || OnMapSpawn || traffLightRelay1 || Trigger || &nbsp; || 0.00 || Yes
|}
|}


4. Select <code>traffLightRelay1</code>.
Add these outputs to the ''first'' {{ent|logic_relay}}:
 
5. in outputs this:


{| {{OutputsTable}}
{| {{OutputsTable}}
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 28.00 || No || '''yellow in 28 sec'''
| [[File:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 28.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || redLight || LightOff || &nbsp; || 30.00 || No || '''Red'''
| [[File:Io11.png]] || OnTrigger || redLight || LightOff || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 30.00 || No || '''Green'''
| [[File:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOff || &nbsp; || 30.00 || No || '''Turn off yellow'''
| [[File:Io11.png]] || OnTrigger || yellowLight || LightOff || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || traffLightRelay2 || Trigger || &nbsp; || 32.00 || No || <i><b>Continue in second part</b></i>
| [[File:Io11.png]] || OnTrigger || traffLightRelay2 || Trigger || &nbsp; || 32.00 || No
|}
|}


{{Note:ru|In this system we need to create 2 <code>logic_relay</code> for make them cicle. First: red -> green. Second: green -> red. Each logic_relay connected with each other.}}
{{note|This tutorial will use both {{ent|logic_relay|alt=logic_relays}} and trigger them one after another}}
 
6. Select <code>traffLightRelay2</code>.


7. In Outputs:
Add these outputs to the ''second'' {{ent|logic_relay}}:


{| {{OutputsTable}}
{| {{OutputsTable}}
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 28.00 || No || '''green blink'''
| [[File:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 28.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 28.50 || No || '''blink'''
| [[File:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 28.50 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 29.00 || No || '''blink'''
| [[File:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 29.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 29.50 || No || '''blink'''
| [[File:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 29.50 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 30.00 || No || '''End blink. Turn off green'''
| [[File:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 30.00 || No || '''Turn off yellow'''
| [[File:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || redLight || LightOn || &nbsp; || 32.00 || No || '''turn on red'''
| [[File:Io11.png]] || OnTrigger || redLight || LightOn || &nbsp; || 32.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || traffLightRelay1 || Trigger || &nbsp; || 32.00 || No || '''activate first part'''
| [[File:Io11.png]] || OnTrigger || traffLightRelay1 || Trigger || &nbsp; || 32.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOff || &nbsp; || 32.00 || No || '''we forget turn off yellow! :D'''
| [[File:Io11.png]] || OnTrigger || yellowLight || LightOff || &nbsp; || 32.00 || No
|}
|}


It is all! ;).
Now the map can be compiled and the traffic lights should be working!


[[Image:TrafflightScheme.jpg|640px|thumb|center|I make schematics for this chaos:)]]
=External links=


--[[User:Kostya|]{o$Tya]] [[File:Itisme.jpg|200px|It is me B-)]] 14:39, 24 May 2011 (UTC)
[http://depositfiles.com/files/o2fdncelg '''vmf + bsp + screenshots <big>(Counter-Strike: Source!)</big>'''] {{dead link}}


[[Category:Level Design Tutorials]]
[[Category:Level Design]]
[[Category:Tutorials]]

Latest revision as of 09:35, 28 May 2025

English (en)Русский (ru)Translate (Translate)

The Half-Life 2 Half-Life 2 assets already provide a model of a signal light, this tutorial will explain how a dynamic traffic light can be set up using I/O.

Required entities

Keyvalue Value
World Model Fileprops_c17\traffic_light001a.mdl
Disable Shadows Yes
Collide with world Not solid
Note.pngNote:"Not solid" is necessary when you want to place the lights inside the model or very close to it


I/O setup

CBETOFOPkpacHbIu.jpg


The input and output logic will define how long each light will be visible, this example will use the following durations:

  • Red and green - 30 seconds
  • Yellow - 3 seconds

Entity names

CBETOFOPredYellow.jpg

The targetname keyvalue defines the name of the entities, the three point_spotlights should use the following names respectively: "greenLight" "redLight" "yellowLight". The first logic_relay will be named "traffLightRelay1" and the second one "traffLightRelay2".

Outputs

CBETOFOPgreen.jpg
CBETOFOPyellow.jpg

The logic_auto requires the following output:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnMapSpawn traffLightRelay1 Trigger   0.00 Yes

Add these outputs to the first logic_relay:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger yellowLight LightOn   28.00 No
Io11.png OnTrigger redLight LightOff   30.00 No
Io11.png OnTrigger greenLight LightOn   30.00 No
Io11.png OnTrigger yellowLight LightOff   30.00 No
Io11.png OnTrigger traffLightRelay2 Trigger   32.00 No
Note.pngNote:This tutorial will use both logic_relays and trigger them one after another

Add these outputs to the second logic_relay:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger greenLight LightOff   28.00 No
Io11.png OnTrigger greenLight LightOn   28.50 No
Io11.png OnTrigger greenLight LightOff   29.00 No
Io11.png OnTrigger greenLight LightOn   29.50 No
Io11.png OnTrigger greenLight LightOff   30.00 No
Io11.png OnTrigger yellowLight LightOn   30.00 No
Io11.png OnTrigger redLight LightOn   32.00 No
Io11.png OnTrigger traffLightRelay1 Trigger   32.00 No
Io11.png OnTrigger yellowLight LightOff   32.00 No

Now the map can be compiled and the traffic lights should be working!

External links

vmf + bsp + screenshots (Counter-Strike: Source!) [dead link]