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

Creating a rotating portalgun

From Valve Developer Community
Jump to: navigation, search
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