PolyObject Tutorial

From SRB2 Wiki
Jump to: navigation, search

PolyObjects are sectors created outside of the main map that are spawned with the use of Things, thus making them able to move horizontally and rotate. Additionally, their visibility can be modified through linedef executors. This tutorial shows the setup of a basic PolyObject, usage of their actions, as well as more complex settings.

Contents

Basic PolyObject

Introduction

To create a basic PolyObject, two linedef specials are needed: Linedef Type 20 is given to one linedef of a PolyObject to make the game recognize it as such, Linedef Type 22 is used to specify the settings of the PolyObject. Also required are two Things: the PolyObject Spawn Point and the PolyObject Anchor. These are used to specify where the PolyObject will appear.

The following basic terms appear when making a PolyObject:

  • PolyObject Sector: The actual PolyObject. It is placed outside of the main map. One of its linedefs has to have Linedef Type 20 though it doesn't matter which one.
  • Surrounding Sector: Around the PolyObject, an additional sector has to be created. This sector needs to have the same properties as the sector that will surround the PolyObject in the actual level, which means same floor and ceiling height, same light level and same flats.
  • Control Sector or Parameter Sector: An additional control sector has to be created to set the parameters of the PolyObject. Otherwise, the game will crash. One of its linedefs has to have Linedef Type 22.
  • PolyObject Anchor: This must be placed anywhere inside the surrounding sector, though it doesn't have to be inside the PolyObject sector itself. This is sort of the focal point for the PolyObject, and all movements will be performed around this point.
  • PolyObject Spawn Point: This is where the PolyObject Anchor will appear inside the main map. Use a PolyObject Spawn Point (Crush) to make the PolyObject kill the player when they touch it and it is moving too fast.
  • PolyObject ID: Each PolyObject has a separate "identification number" that is used a couple of times. Both linedef have this as their tag and both Things have it as their Angle. The Control Sector also has this as its floor height.

Instructions

Depending on what you want to do with your PolyObject, the Anchor can be placed in different points. For rotating or horizontally moving PolyObjects, it's usually best to have the Anchor in the middle, while swinging PolyObjects mostly have them to the side. For very complex PolyObjects, the Anchor might not even be in the PolyObject itself. To learn the basics of PolyObject creation, it's best to start with the most simple shape, which is a cube with its Anchor in the middle.

Start by placing the PolyObject Spawn Point where you want the PolyObject to appear in the map. The Angle of this Thing must be the PolyObject ID. This should be the next unused tag, which in the case of a test map would usually be 1. Then, create a sector outside the map that is big enough to contain your PolyObject sector. Since our test PolyObject is a cube, this sector should be a square that is bigger than the PolyObject. This is the surrounding sector, so it has to have the same attributes as the sector the Spawn Point is in. You can do this automatically by joining both sectors.

Inside this surrounding sector, create the PolyObject sector. In this case, it would be a simple square. It is very important to make all linedefs face outward. The notches in the middle of the linedef should face the surrounding sector, not the PolyObject sector itself. Now pick any linedef of this newly created sector and give it Linedef Type 20. The tag should be the PolyObject ID, which is again 1 in this case. In the middle of the PolyObject sector, place the PolyObject Anchor, again with a tag of 1. Floor height and ceiling height are also set in the PolyObject sector, simply as floor and ceiling height of the sector.

In its current state, loading this map would crash the game with an error message. This is because the PolyObject is missing a Parameter sector. To fix this, create a new control sector and give on of its linedefs Linedef Type 22. Both the tag of the linedef and the floor height of the Parameter sector should be the PolyObject ID (again, 1 in this case).

If you test the map now, it loads properly, but the PolyObject doesn't show up. Walking towards it stops the player anyway, because the PolyObject is there, but currently doesn't have any textures set, making it invisible. The textures are set as the front middle textures in the PolyObject sector, for every linedef separately: PolyObjects are regular sectors, not FOFs, so every linedef must have its own texture specified. Missing textures, however, don't produce glitches of any sort, they just stay invisible. Flats don't have to be set, since they are not displayed.

Because PolyObjects use middle textures, they are only rendered once by default. For example, if your texture is 128 fracunits high (which is the case with most textures) but your PolyObject is 256 fracunits high, only the upper half will have visible textures. To fix this, you must give every linedef the Effect 5 flag and set the front texture X offsets to the height of the PolyObject.

Actions

The PolyObject actions range from Linedef Types 480 to 491, and contains horizontal movement, rotation and visibility effects. They are set up like regular linedef executors, in a separate control sector, with a trigger and an executor. The tag of the executor is the PolyObject ID. For continuous movement or rotation effects that should be performed on level load, Linedef Type 399 can be used as the trigger.

Horizontal Movement

There are four linedef types for horizontal PolyObject movement, each for slightly different purposes and with slightly different effects:

  • Linedef Type 480, Door Slide, is used for PolyObjects that move a certain distance and then back again, performing this action only once. The effect is controlled through the texture offsets: The front texture X offset determines the speed, the front texture Y offset determines how far it will slide (in the direction that the control linedef is facing), and the back texture X offset determines how long to wait before sliding back, in tics.
  • Linedef Type 482, Move, works identical to the door slide effect, only that the PolyObject won't move back. This is best used for horizontal platforms that takes the player from one point to another. It is set up the same way, but the back texture X offset is not needed.
  • Linedef Type 483, Move and Override, is a copy of the aforementioned Move linedef that overrides other actions. If you want this effect to be executed simultaneously to another action, use this instead of Linedef Type 482.
  • Linedef Type 488, Move by Waypoints, is the most flexible and least specific movement linedef. With this, you can make a PolyObject have complex movement schemes and also repeat the effect indefinitely. Front texture X offset determines the speed, and front texture Y offset determines the Zoom Tube Waypoint sequence that it will move through. The PolyObject starts at its Spawn Point and will then move to the first waypoint and through all the others. If the Effect 1 flag is checked, it will go through the sequence in reverse, and if the Effect 2 flag is checked, it will go through the sequence in both directions. If the Effect 3 flag is checked, it will return to the first waypoint after moving, and if the Effect 4 flag is checked with either Effect 2 or Effect 3, it will loop the movement. This is useful for horizontal pushers when combined with the level load trigger linedef.

Note that moving PolyObjects out of the sector they spawn in might lead to rendering glitches.

Rotation

There are five linedef types for PolyObject rotation, each for slightly different purposes and with slightly different effects:

  • Linedef Type 481, Door Swing, is used for PolyObjects that rotate around their Anchor and then back again, performing this action only once. If you want a PolyObject to swing like a door would, the Anchor must be placed at the side that will remain stationary. The effect is controlled through the texture offsets: The front texture X offset determines the speed, the front texture Y offset determines how far it will swing in degrees, and the back texture X offset determines how long to wait before rotating back, in tics.
  • Linedef Type 484, Rotate Right, makes a PolyObject rotate clockwise around its Anchor. If the Anchor is not inside the PolyObject itself, it will rotate around it. The front texture X offset determines the speed, the front texture Y offset determines how far it will rotate in degrees. If the Effect 4 flag is checked and the Y offset set to 360, it will rotate continuously.
  • Linedef Type 485, Rotate Right and Override, is a copy of the aforementioned Rotate linedef that overrides other actions. If you want this effect to be executed simultaneously to another action, use this instead of Linedef Type 484.
  • Linedef Type 486 and Linedef Type 487 work the same as the above two linedef executors, but make the PolyObject rotate counterclockwise instead.

Visibility Effects

There are three linedef types that control tangibility, visibility and translucency:

  • Linedef Type 489, Turn Invisible and Intangible, makes a PolyObject turn invisible and intangible. If the Not Climbable flag is set, the PolyObject will only turn invisible, but stay tangible.
  • Linedef Type 490, Turn Visible and Tangible, makes a PolyObject turn visible and tangible. If the Not Climbable flag is set, the PolyObject will only turn visible, but stay intangible.
  • Linedef Type 491, Set Translucency, set the translucency of a PolyObject. The floor height determines how translucent it will be, with 0 being completely opaque and 1000 completely invisible.

Setting Up an Action

As an example of how to set up a PolyObject action, we choose the most versatile and useful, but also the most complicated effect: Move By Waypoints. The first part is similar for all actions, while the setup of the waypoints and the flag usage only pertain to this specific effect. For this tutorial we will choose three waypoints to properly showcase how the effect flags work.

Control Sector

Create a new control sector, tag one of its linedefs to the PolyObject ID and give Linedef Type 488. A second line should be either a regular trigger linedef or Linedef Type 399 if the action should be performed on spawn. Now, set the necessary atrributes in the sidedefs tab of that linedef. The front texture X offset sets the speed, 32 is normal. The front texture Y offset sets the waypoint sequence to use. If this is the first set of Zoom Tube Waypoints in your level, leave it as zero. For each new waypoint sequence, add 1. Each PolyObject should have its own waypoint sequence, as should every Zoom Tube.

Waypoints

For the purpose of our tutorial, place three Zoom Tube Waypoints on the map, it doesn't matter where. The Angle determines their order. The first waypoint has an Angle of 0, the second an Angle of 1, and so forth. For each new waypoint sequence, add 256 to the Angles of all waypoints belonging to it. The Z offset should be the center of the PolyObject, so if it is 128 fracunits high, the waypoints should be at 64, unless you want the PolyObject to move up and down as well. If you run the map now, the PolyObject will move from its Spawn Point to the first waypoint and then onto the next ones in ascending order, until it stops at the last one. If you want it to start at the first waypoint, simply place the Spawn Point at the same spot so that they overlap.

Flags Usage

The flags of the control linedef control how the PolyObject will go through the waypoints. Through using and combining the Effect 1 to Effect 4 flags, several possibilities can be exhibited:

Effect Flags Behavior Example
None From first to last waypoint Spawn Point - Waypoint 1 - Waypoint 2 - Waypoint 3
Effect 1 From last to first waypoint Spawn Point - Waypoint 3 - Waypoint 2 - Waypoint 1
Effect 2 From first to last waypoint, then to first Spawn Point - Waypoint 1 - Waypoint 2 - Waypoint 3 - Waypoint 2 - Waypoint 1
Effect 1 and Effect 2 From last to first waypoint, then to last Spawn Point - Waypoint 3 - Waypoint 2 - Waypoint 1 - Waypoint 2 - Waypoint 3
Effect 3 From first to last waypoint, then directly to first Spawn Point - Waypoint 1 - Waypoint 2 - Waypoint 3 - Waypoint 1
Effect 1 and Effect 3 From last to first waypoint, then directly to last Spawn Point - Waypoint 3 - Waypoint 2 - Waypoint 1 - Waypoint 3
Effect 4 Loops movement (must be used at least with either Effect 2 or Effect 3) Spawn Point - Waypoint 1 - Waypoint 2 - Waypoint 3 - Waypoint 1 - Waypoint 2 - Waypoint 3 - etc.

Special Settings

  • Linedef Type 316 is a trigger linedef executor made specifically for PolyObjects. It activates upon touching the floor of a PolyObject whose First Line (the linedef with Type 20) has the Not Climbable flag checked. The tag of this linedef should the PolyObject ID plus 32000.
  • Linedef Type 30 makes the First Line of a PolyObject shift back and forth without needing a linedef executor. This is useful for flags that wave in the wind.

Samples

Sample 1

Example WAD: ex_ld020_polyobject.wad

Notes

  • This example WAD can be played in any gametype. It uses MAP01, replacing Greenflower Zone Act 1.
  • This shows a basic PolyObject that doesn't perform any actions.

Sample 2

Example WAD: ex_ld488_polyobject_movebywaypoints.wad

Notes


Sample 3

Example WAD: ex_ld316_landonpolyobject.wad

Notes

  • This example WAD can be played in any gametype. It uses MAP01, replacing Greenflower Zone Act 1.
  • This shows a PolyObject that plays the THZ Alarm sound upon being touched.
Personal tools