Create traffic lights: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(I translate. sorry for baD english! ^-^)
 
(fixed translation)
Line 3: Line 3:
}}
}}


= Traffic lights :) outputs and inputs=
The [[Half-Life 2]] resources 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|inputs and outputs]].


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==
* a <code><b>[[prop_dynamic]]</b></code> with the following keyvalues:


* Model <code>props_c17\Traffic_Light001a.mdl</code> <code><b>prop_dynamic</b></code>
:'''World Model = props_c17\Traffic_Light001a.mdl'''


* color lights: <code>point_spotlight</code>s on each lights =).
:'''Disable Shadows = Yes'''


* model properties:
:'''Collide with world = Not solid''' (necessary when you want to place the lights inside the model or very close to it)


:'''Disable Shadows=Yes'''
* three <code><b>[[point_spotlight|point_spotlights]]</b></code> 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 <code><b>[[logic_auto]]</b></code>


* one <code>logic_auto</code>, two <code>logic_relay</code>.
* two <code><b>[[logic_relay|logic_relays]]</b></code>.




Line 27: Line 27:
[[File:CBETOFOPyellow.jpg|240px|thumb|right]]
[[File:CBETOFOPyellow.jpg|240px|thumb|right]]


=='''In details...'''==
==I/O setup==


'''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===


1. give ''targetname''s for each of 3 point_spotlight with names: "greenLight" "redLight" "YellowLight". 1 logic_relay call traffLightRelay1, 2 - traffLightRelay2.
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".


2. select logic_auto
===Outputs===


3. in outputs
The logic_auto requires the following output:


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


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


{| {{OutputsTable}}
{| {{OutputsTable}}
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 28.00 || No || '''yellow in 28 sec'''
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 28.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || redLight || LightOff || &nbsp; || 30.00 || No || '''Red'''
| [[Image:Io11.png]] || OnTrigger || redLight || LightOff || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 30.00 || No || '''Green'''
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOff || &nbsp; || 30.00 || No || '''Turn off yellow'''
| [[Image: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>
| [[Image: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 logic_relay and trigger them one after another}}
 
6. Select <code>traffLightRelay2</code>.


7. In Outputs:
Add these outputs to the ''second'' logic_relay:


{| {{OutputsTable}}
{| {{OutputsTable}}
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 28.00 || No || '''green blink'''
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 28.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 28.50 || No || '''blink'''
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 28.50 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 29.00 || No || '''blink'''
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 29.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 29.50 || No || '''blink'''
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOn || &nbsp; || 29.50 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 30.00 || No || '''End blink. Turn off green'''
| [[Image:Io11.png]] || OnTrigger || greenLight || LightOff || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 30.00 || No || '''Turn off yellow'''
| [[Image:Io11.png]] || OnTrigger || yellowLight || LightOn || &nbsp; || 30.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || redLight || LightOn || &nbsp; || 32.00 || No || '''turn on red'''
| [[Image:Io11.png]] || OnTrigger || redLight || LightOn || &nbsp; || 32.00 || No
|-
|-
| [[Image:Io11.png]] || OnTrigger || traffLightRelay1 || Trigger || &nbsp; || 32.00 || No || '''activate first part'''
| [[Image: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'''
| [[Image: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:)]]
 
--[[User:Kostya|]{o$Tya]] [[File:Itisme.jpg|200px|It is me B-)]] 14:39, 24 May 2011 (UTC)


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

Revision as of 08:30, 24 May 2011

Template:Otherlang2

The Half-Life 2 resources 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.

required Entities

World Model = props_c17\Traffic_Light001a.mdl
Disable Shadows = Yes
Collide with world = Not solid (necessary when you want to place the lights inside the model or very close to it)


CBETOFOPkpacHbIu.jpg
CBETOFOPredYellow.jpg
CBETOFOPgreen.jpg
CBETOFOPyellow.jpg

I/O setup

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

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

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_relay 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!