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
No edit summary
 
(66 intermediate revisions by 19 users not shown)
Line 1: Line 1:
{{wip}}
{{LanguageBar}}
== Introduction ==
{{Portal topicon}}
[[Image:Picture_03.jpg|right|Width:64]]
[[File:Picture_03.jpg|right|thumb|The pedestal in-game.]]
So, we are going to create rotating stand with portalgun shooting portals.
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:
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>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>pedestal_top_model</code>. Place it right above <code>pedestal_bottom_model</code> as shown in the image below.


prop_dynamic, world model: models/props/pedestal_base_reference.mdl, name: stand_bottom_model
== Brushes ==
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, centered above the pedestal.
* 4 x 32, height 56, placed next to the pedestal.
[[File:Picture_01.jpg|right|thumb|Placement of the brushes and models.]]


prop_dynamic, world model: models/props/pedestal_center_reference.mdl, name: stand_top_model
== Entities ==


Just create and name them, we will move them after next step
=== Doors ===
Select the 32x32 brush and tie it to a <code>func_door_rotating</code> entity with the following properties:


==Prepare brushes==
::{| class=standard-table
Create:
!  Property Name || Value
|-
| Name || pedestal_rotating_door
|-
| Delay Before Reset || -1
|-
| Spawn Position || Closed
|-
| Speed || 30
|-
| Distance || 90
|}


32 to 32 square, height 4, using nodraw texture.
Check the <code>Passable</code> flag.


4 to 32 sq, height 55 with nodraw texture too.
Tie the second brush to a <code>func_door</code> set to these properties:


==Moving==
::{| class=standard-table
!  Property Name || Value
|-
| Name || pedestal_retracting_door
|-
| Speed || 20
|-
| Stop Sound || Doors.FullOpen9
|-
| Move direction: || 90 0 0
|-
| Delay Before Reset || -1
|-
| Lip || 1
|}


[[Image:Picture_01.jpg|right|thumb|Illustration 1.]]
Check the <code>Passable</code> flag on this as well.
Move stand_bottom_model where you want to have the stand, that small doors on it have to be under ground.
Then move stand_top_model above stand_bottom_model, as on picture //soon// .
Center 1st brush, that 32x32, with stand_top_model, Z axis to half of stand_top_model (approximately).
And move 2nd brush as on picture.


==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 new entity, weapon_portalgun and name it weapon_portalgun.
=== Sounds ===
Move it exactly to top of stand_top_model, a front part of portalgun has to be on left when you’re loking on stand_top_model from that part with blue display.  
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>.


==Logic==
== Entity outputs ==


Make entity logic_timer named timer_stand and set interval to 5 sec. Make sure that initial state is on.
Add the following outputs to <code>pedestal_rotating_door</code>:
Now go to outputs and write:
::{|
::{| 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
|-
| [[File:Io11.png]] || OnFullyOpen || pedestal_top_model || ClearParent ||  || 0.00 || No
|-
| [[File:Io11.png]] || OnFullyOpen || pedestal_rotating_door || Close ||  || 0.01 || No
|-
|-
| [[Image:Io11.png]] || OnTimer || stand_func_rotating || Stop || <none> || 3.00 || No
| [[File:Io11.png]] || OnFullyOpen || pedestal_gun || ChargePortal1 || || 2.00 || No
|-
|-
| [[Image:Io11.png]] || OnTimer || weapon_portalgun || FirePortal1 || <none> || 3.00 || No
| [[File:Io11.png]] || OnFullyOpen || pedestal_sound_charge || PlaySound ||  || 2.00 || No
|-
| [[File:Io11.png]] || OnFullyOpen || pedestal_gun || FirePortal1 || || 3.00 || No
|-
| [[File:Io11.png]] || OnFullyClosed || pedestal_rotating_door || Open ||  || 5.00 || No
|-
| [[File:Io11.png]] || OnOpen || pedestal_sound_rotate || PlaySound ||  || 0.00 || 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>.


Select 32x32 brush and tie it to entity func_rotating.
Add the following output to <code>pedestal_retracting_door</code>:
Name: stand_func_rotating |
::{| class=standard-table
Friction: 0 |
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once 
Max Rotation Speed: 30 |
|-
In Flags, unmark Start ON.
| [[File:Io11.png]] || OnFullyOpen || pedestal_bottom_model || SetAnimation || close || 0.00 || No 
|}


Tie 2nd brush to func_door.
Add the following outputs to <code>pedestal_gun</code>:
Name: stand_func_door |
::{| class=standard-table
Speed: 25 |
Move direction: 90 0 0 //Down.
Create new output:
::{|
!  || 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]] || OnPlayerPickup || pedestal_top_model || SetParent || pedestal_retracting_door || 0.00 || No
|-
| [[File:Io11.png]] || OnPlayerPickup || pedestal_rotating_door || Kill ||  || 0.10 || No
|-
| [[File:Io11.png]] || OnPlayerPickup || pedestal_retracting_door || Open ||  || 1.00 || No
|-
| [[File:Io11.png]] || OnPlayerPickup || pedestal_top_model || SetAnimation || close || 1.00 || No
|}
|}


== 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.]]


Now, we will make outputs of stand_bottom_model:
== Fixes involving the rotating portalgun ==
::{|
 
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
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.
|-
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.
| [[Image:Io11.png]] || OnAnimationDone || stand_bottom_model || SetAnimation || inactive || 0.00 || No
|}


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


And few outputs for weapon_portalgun:
=== 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 <code>tools/toolstrigger</code> centered on the pedestal. Tie it to a {{ent|trigger_once}} entity with the following outputs:
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
::{| 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]] || OnStartTouch || pedestal_top_model || SetAnimation || open || 0.00 || No
|-
|-
| [[Image:Io11.png]] || OnPlayerPickup || stand_top_model || SetParent || stand_func_door || 0.00 || No
| [[File:Io11.png]] || OnStartTouch || pedestal_sound_open || PlaySound || || 0.00 || No   
|-
| [[Image:Io11.png]] || OnPlayerPickup || stand_func_door || Open || || 0.80 || 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>.


==Parents and the Hole==
== See also ==
 
* [[Portal Level Creation]]
[[Image:Picture_02.jpg|right|thumb|Illustration 2. I moved all, just for illustration of hole.]]
Now, just set parent of weapon_portalgun and stand_top_model to stand_func_rotating.
When your done, make hole under stand_bottom_models overground part.
 
==End==


You may create prop_static with model of models/props/autoportal_frame/autoportal_frame.mdl for framing autofired portals, just move them to wall and rotate.
[[Category:Portal]] [[Category:Level Design]] [[Category:Tutorials]]

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