This article relates to the game "Portal". Click here for more information.

Creating a rotating portalgun: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(32 intermediate revisions by 11 users not shown)
Line 1: Line 1:
== Introduction ==
{{LanguageBar}}
[[Image:Picture_03.jpg|right|Width:64]]
{{Portal topicon}}
In this tutorial we will be creating a rotating stand with a mounted portalgun that automatically shoots portals.
[[File:Picture_03.jpg|right|thumb|The pedestal in-game.]]
In this tutorial we will be creating a portal gun pedestal which automatically rotates and fires portals in four directions.


== Prepare models ==
== Models ==
You will need two {{ent|prop_dynamic}} entities, one for each of the following world models:
You will need two {{ent|prop_dynamic}} entities, one for each of the following world models:
* <code>models/props/pedestal_base_reference.mdl</code>. Name it <code>stand_bottom_model</code> and set its "disableshadows" keyvalue to 1.
* <code>models/props/pedestal_base_reference.mdl</code>. Name it <code>pedestal_bottom_model</code> and set its "Disable Shadows" keyvalue to Yes. Place it on the ground where you want the pedestal to be, with the small doors just below the ground.
* <code>models/props/pedestal_center_reference.mdl</code>. Name it <code>stand_top_model</code>.
* <code>models/props/pedestal_center_reference.mdl</code>. Name it <code>pedestal_top_model</code>. Place it right above <code>pedestal_bottom_model</code> as shown in the image below.


== Prepare brushes ==
== Brushes ==
Create two brushes with the following dimensions:
Create two brushes, both textured with the <code>[[tool textures|tools/nodraw]]</code> texture. These will be tied to entities later on.
* 32 x 32, height 4, using the <code>[[tool textures|tools/nodraw]]</code> texture.
* 32 x 32, height 4, centered above the pedestal.
* 4 x 32, height 56, also using the <code>tools/nodraw</code> texture.
* 4 x 32, height 56, placed next to the pedestal.
[[File:Picture_01.jpg|right|thumb|Placement of the brushes and models.]]


== Moving ==
== Entities ==
[[Image:Picture_01.jpg|right|thumb|Brush and model placement.]]
Move <code>stand_bottom_model</code> where you want to have the stand. The small doors on the bottom of the model need to be just underground. Now move <code>stand_top_model</code> above <code>stand_bottom_model</code> as shown in the picture on the right.


Center the first brush (the one that measured 32x32) with <code>stand_top_model</code>. Set its Z axis (height) to about half of <code>stand_top_model</code>.
=== Doors ===
Now move the second brush to the side of the stand, as it is shown in the picture on the right.
{{clr}}
== Brush Entities ==
Select the 32x32 brush and tie it to a <code>func_door_rotating</code> entity with the following properties:
Select the 32x32 brush and tie it to a <code>func_door_rotating</code> entity with the following properties:


Line 26: Line 23:
!  Property Name || Value
!  Property Name || Value
|-
|-
| Name || stand_func_rotating
| Name || pedestal_rotating_door
|-
|-
| Delay Before Reset || -1
| Delay Before Reset || -1
Line 36: Line 33:
| Distance || 90
| Distance || 90
|}
|}
Check the <code>Passable</code> flag.


Tie the second brush to a <code>func_door</code> set to these properties:  
Tie the second brush to a <code>func_door</code> set to these properties:  
Line 42: Line 41:
!  Property Name || Value
!  Property Name || Value
|-
|-
| Name || stand_func_door
| Name || pedestal_retracting_door
|-
|-
| Speed || 25
| Speed || 20
|-
| Stop Sound || Doors.FullOpen9
|-
|-
| Move direction: || 90 0 0
| Move direction: || 90 0 0
Line 53: Line 54:
|}
|}


Under the Flags tab, check <code>Passable</code>.
Check the <code>Passable</code> flag on this as well.


== PortalGun ==
=== Portal Gun ===
Create a <code>weapon_portalgun</code> and name it <code>pedestal_gun</code>. Move it exactly on top of <code>pedestal_top_model</code>. The portalgun should face left when you’re looking at the pedestal from the front (the side with the blue arrow display), like the one shown in the first picture at the [[{{PAGENAME}}#top|top]] of this page. You may wish to disable the "Can Fire Portal 1" or "Can Fire Portal 2" keyvalues to give the player a single-color portal gun.


Create a new entity, a <code>weapon_portalgun</code> and name it <code>weapon_portalgun</code>.
=== Sounds ===
Move it exactly on top of <code>stand_top_model</code>. The portalgun should face left when you’re looking at <code>stand_top_model</code> in the direction of the blue arrow display, like the one shown in the first picture on the [[{{PAGENAME}}#top|top]] of this page.
Create three <code>ambient_generic</code> entities. Set the following properties on each one:
* Name the first <code>pedestal_sound_rotate</code>, set its sound name to <code>Portalgun.pedestal_rotate</code> and the Source Entity to <code>pedestal_top_model</code>.
* Name the second <code>pedestal_sound_charge</code>, set its sound name to <code>Weapon_CombineGuard.Special1</code> and the Source Entity to <code>pedestal_gun</code>.
* Name the third <code>pedestal_sound_open</code>, set its sound name to <code>Buttons.snd22</code> and the Source Entity to <code>pedestal_top_model</code>.


== Defining entity outputs ==
== Entity outputs ==


Now go to its outputs tab and write:
Add the following outputs to <code>pedestal_rotating_door</code>:
::{| class=standard-table
::{| class=standard-table
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
|-
|-
| [[Image:Io11.png]] || OnTimer || stand_func_rotating || Start || <none> || 0.00 || No
| [[File:Io11.png]] || OnFullyClosed || pedestal_top_model || SetParent || pedestal_rotating_door || 0.00 || No
|-
|-
| [[Image:Io11.png]] || OnTimer || stand_func_rotating || Stop || <none> || 3.00 || No
| [[File:Io11.png]] || OnFullyOpen || pedestal_top_model || ClearParent || || 0.00 || No
|-
|-
| [[Image:Io11.png]] || OnTimer || weapon_portalgun || FirePortal1 || <none> || 3.00 || No
| [[File:Io11.png]] || OnFullyOpen || pedestal_rotating_door || Close || || 0.01 || No
|}
 
Now go to the func_door_rotatings outputs tab and write:
::{| class=standard-table
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
|-
|-
| [[Image:Io11.png]] || OnFullyClosed || stand_top_model || SetParent || stand_func_door || 0.00 || No
| [[File:Io11.png]] || OnFullyOpen || pedestal_gun || ChargePortal1 || || 2.00 || No
|-
|-
| [[Image:Io11.png]] || OnFullyClosed || weapon_portalgun || SetParent || stand_func_door || 0.00 || No
| [[File:Io11.png]] || OnFullyOpen || pedestal_sound_charge || PlaySound || || 2.00 || No
|-
|-
| [[Image:Io11.png]] || OnFullyClosed || weapon_portalgun || FirePortal1 || <none> || 0.00 || No
| [[File:Io11.png]] || OnFullyOpen || pedestal_gun || FirePortal1 || || 3.00 || No
|-
|-
| [[Image:Io11.png]] || OnFullyClosed || stand_func_rotating || Open || <none> || 0.01 || No
| [[File:Io11.png]] || OnFullyClosed || pedestal_rotating_door || Open || || 5.00 || No
|-
|-
| [[Image:Io11.png]] || OnFullyOpen || stand_top_model || SetParent || stand_func_rotating || 0.00 || No
| [[File:Io11.png]] || OnOpen || pedestal_sound_rotate || PlaySound || || 0.00 || No
|-
| [[Image:Io11.png]] || OnFullyOpen || weapon_portalgun || SetParent || stand_func_rotating || 0.00 || No
|-
| [[Image:Io11.png]] || OnFullyOpen || stand_func_rotating || Close || <none> || 0.01 || No
|}
|}
To make the pedestal instead fire orange portals, replace <code>ChargePortal1</code> with <code>ChargePortal2</code> and <code>FirePortal1</code> with <code>FirePortal2</code>.


Create a new output for stand_func_door:  
Add the following output to <code>pedestal_retracting_door</code>:  
::{| class=standard-table
::{| class=standard-table
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once   
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once   
|-
|-
| [[Image:Io11.png]] || OnFullyOpen || stand_bottom_model || SetAnimation || close || 0.00 || No   
| [[File:Io11.png]] || OnFullyOpen || pedestal_bottom_model || SetAnimation || close || 0.00 || No   
|}
|}


 
Add the following outputs to <code>pedestal_gun</code>:
Now, we will make outputs of <code>stand_bottom_model</code>:
::{| class=standard-table
::{| class=standard-table
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
|-
|-
| [[Image:Io11.png]] || OnAnimationDone || stand_bottom_model || SetAnimation || inactive || 0.00 || No
| [[File:Io11.png]] || OnPlayerPickup || pedestal_top_model || SetParent || pedestal_retracting_door || 0.00 || No
|}
 
 
And few outputs for <code>weapon_portalgun</code>:
::{| class=standard-table
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
|-
|-
| [[Image:Io11.png]] || OnPlayerPickup || timer_stand || Kill || || 0.00 || No
| [[File:Io11.png]] || OnPlayerPickup || pedestal_rotating_door || Kill || || 0.10 || No
|-
|-
| [[Image:Io11.png]] || OnPlayerPickup || stand_top_model || SetParent || stand_func_door || 0.00 || No
| [[File:Io11.png]] || OnPlayerPickup || pedestal_retracting_door || Open || || 1.00 || No
|-
|-
| [[Image:Io11.png]] || OnPlayerPickup || stand_func_door || Open || || 0.80 || No
| [[File:Io11.png]] || OnPlayerPickup || pedestal_top_model || SetAnimation || close || 1.00 || No
|}
|}


== Parents and the hole ==
== Parenting and creating the hole ==
Now just parent <code>pedestal_gun</code> to <code>pedestal_top_model</code>, and that to <code>pedestal_rotating_door</code>. Since the pedestal retracts into the floor, you will need to make a cylindrical hole on the floor beneath <code>pedestal_bottom_model</code>, like the one shown in the image to the right.
[[File:Picture_02.jpg|right|thumb|All done. Notice the hole in the floor.]]


[[Image:Picture_02.jpg|right|thumb|All done. Notice the hole created on the floor.]]
== Fixes involving the rotating portalgun ==
Now, just set the parent of <code>weapon_portalgun</code> and <code>stand_top_model</code> to <code>stand_func_rotating</code>.
When you're done, make a cylindrical hole on the floor beneath <code>stand_bottom_model</code>, like the one shown in the image to the right.


== End ==
You will need to have an entity that triggers an <code>Open</code> input in <code>pedestal_rotating_door</code>, otherwise it won't do anything.
Additionally, you may want to create a portal frame on each wall the portals are going to be fired at.
For example, in my map, I have a trigger entity surrounding the player so that as soon as the player spawns in, the Open input is triggered on <code>pedestal_rotating_door</code>. You can also use a button, if you so please.


To do this, create a {{ent|prop_static}} entity with the model <code>models/props/autoportal_frame/autoportal_frame.mdl</code>, move it to the wall you wish to place it at, and rotate it until it is parallel to the wall.
== Optional features ==
=== Portal frames ===
You may want to create a portal frame on each wall the portals are going to be fired at. To do this, create a {{ent|prop_static}} entity with the model <code>models/props/autoportal_frame/autoportal_frame.mdl</code>, move it to the wall you wish to place it at, and rotate it until it is parallel to the wall.


Or, you can make a brush-based portal frame with the following parameters:
=== Pedestal opening animation ===
* Size of each brush: 8 x 4, height is 128
You may also want to make the pedestal open when the player gets near it. To do this, create a 192 x 192, 128 high brush with the <code>tools/toolstrigger</code> centered on the pedestal. Tie it to a {{ent|trigger_once}} entity with the following outputs:
* Gap between two brushes: 64
::{| class=standard-table
* Front texture: <code>signage/fixed_portal_border</code>
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once 
* Side texture: <code>signage/signage_border</code>
|-
| [[File:Io11.png]] || OnStartTouch || pedestal_top_model || SetAnimation || open || 0.00 || No 
|-
| [[File:Io11.png]] || OnStartTouch || pedestal_sound_open || PlaySound ||  || 0.00 || No 
|}
If you do not do this, you may wish to remove <code>pedestal_sound_open</code> and the output to close the pedestal on <code>pedestal_gun</code>.


== See also ==
== See also ==
* [[Portal Level Creation]]
* [[Portal Level Creation]]


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

Latest revision as of 01:05, 9 June 2025

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

The pedestal in-game.

In this tutorial we will be creating a portal gun pedestal which automatically rotates and fires portals in four directions.

Models

You will need two prop_dynamic entities, one for each of the following world models:

  • models/props/pedestal_base_reference.mdl. Name it pedestal_bottom_model and set its "Disable Shadows" keyvalue to Yes. Place it on the ground where you want the pedestal to be, with the small doors just below the ground.
  • models/props/pedestal_center_reference.mdl. Name it pedestal_top_model. Place it right above pedestal_bottom_model as shown in the image below.

Brushes

Create two brushes, both textured with the tools/nodraw texture. These will be tied to entities later on.

  • 32 x 32, height 4, centered above the pedestal.
  • 4 x 32, height 56, placed next to the pedestal.
Placement of the brushes and models.

Entities

Doors

Select the 32x32 brush and tie it to a func_door_rotating entity with the following properties:

Property Name Value
Name pedestal_rotating_door
Delay Before Reset -1
Spawn Position Closed
Speed 30
Distance 90

Check the Passable flag.

Tie the second brush to a func_door set to these properties:

Property Name Value
Name pedestal_retracting_door
Speed 20
Stop Sound Doors.FullOpen9
Move direction: 90 0 0
Delay Before Reset -1
Lip 1

Check the Passable flag on this as well.

Portal Gun

Create a weapon_portalgun and name it pedestal_gun. Move it exactly on top of pedestal_top_model. The portalgun should face left when you’re looking at the pedestal from the front (the side with the blue arrow display), like the one shown in the first picture at the top of this page. You may wish to disable the "Can Fire Portal 1" or "Can Fire Portal 2" keyvalues to give the player a single-color portal gun.

Sounds

Create three ambient_generic entities. Set the following properties on each one:

  • Name the first pedestal_sound_rotate, set its sound name to Portalgun.pedestal_rotate and the Source Entity to pedestal_top_model.
  • Name the second pedestal_sound_charge, set its sound name to Weapon_CombineGuard.Special1 and the Source Entity to pedestal_gun.
  • Name the third pedestal_sound_open, set its sound name to Buttons.snd22 and the Source Entity to pedestal_top_model.

Entity outputs

Add the following outputs to pedestal_rotating_door:

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnFullyClosed pedestal_top_model SetParent pedestal_rotating_door 0.00 No
Io11.png OnFullyOpen pedestal_top_model ClearParent 0.00 No
Io11.png OnFullyOpen pedestal_rotating_door Close 0.01 No
Io11.png OnFullyOpen pedestal_gun ChargePortal1 2.00 No
Io11.png OnFullyOpen pedestal_sound_charge PlaySound 2.00 No
Io11.png OnFullyOpen pedestal_gun FirePortal1 3.00 No
Io11.png OnFullyClosed pedestal_rotating_door Open 5.00 No
Io11.png OnOpen pedestal_sound_rotate PlaySound 0.00 No

To make the pedestal instead fire orange portals, replace ChargePortal1 with ChargePortal2 and FirePortal1 with FirePortal2.

Add the following output to pedestal_retracting_door:

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnFullyOpen pedestal_bottom_model SetAnimation close 0.00 No

Add the following outputs to pedestal_gun:

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnPlayerPickup pedestal_top_model SetParent pedestal_retracting_door 0.00 No
Io11.png OnPlayerPickup pedestal_rotating_door Kill 0.10 No
Io11.png OnPlayerPickup pedestal_retracting_door Open 1.00 No
Io11.png OnPlayerPickup pedestal_top_model SetAnimation close 1.00 No

Parenting and creating the hole

Now just parent pedestal_gun to pedestal_top_model, and that to pedestal_rotating_door. Since the pedestal retracts into the floor, you will need to make a cylindrical hole on the floor beneath pedestal_bottom_model, like the one shown in the image to the right.

All done. Notice the hole in the floor.

Fixes involving the rotating portalgun

You will need to have an entity that triggers an Open input in pedestal_rotating_door, otherwise it won't do anything. For example, in my map, I have a trigger entity surrounding the player so that as soon as the player spawns in, the Open input is triggered on pedestal_rotating_door. You can also use a button, if you so please.

Optional features

Portal frames

You may want to create a portal frame on each wall the portals are going to be fired at. To do this, create a prop_static entity with the model models/props/autoportal_frame/autoportal_frame.mdl, move it to the wall you wish to place it at, and rotate it until it is parallel to the wall.

Pedestal opening animation

You may also want to make the pedestal open when the player gets near it. To do this, create a 192 x 192, 128 high brush with the tools/toolstrigger centered on the pedestal. Tie it to a trigger_once entity with the following outputs:

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnStartTouch pedestal_top_model SetAnimation open 0.00 No
Io11.png OnStartTouch pedestal_sound_open PlaySound 0.00 No

If you do not do this, you may wish to remove pedestal_sound_open and the output to close the pedestal on pedestal_gun.

See also