A PolyObject is a group of linedefs that can move horizontally, creating the illusion of freely movable sectors. Because SRB2's rendering system relies on pre-calculated information (which is created during the nodebuilding process), normal level geometry is forced to be static. PolyObjects offer a way to circumvent this: The level geometry for the PolyObject is created outside of the main map, while in the map itself it is only represented by a single reference point. During runtime, the game dynamically inserts the PolyObject at the reference point. The reference point can be moved around in the map, thus creating horizontally moving level geometry.
PolyObjects can interact freely with the player and other Objects, and they will carry solid Objects standing on top of them. However, they should never collide with each other or static walls, which will lead to rendering errors. They can move across sector boundaries, but visual glitches may occur if a PolyObject moves into a sector with different properties from the one in which it spawned. PolyObjects should always be convex, since concave PolyObjects are rendered incorrectly, but this can be circumvented by splitting the concave object into multiple convex PolyObjects.
- See also: PolyObject tutorial
At the point in the map where you want the PolyObject to spawn, place a PolyObject Spawn Point. Each PolyObject is referred to by a unique ID, which you can choose freely. Set the Angle of the spawn point to this ID. Then, the level geometry for the PolyObject must be created outside the main map. First, draw a sector that will contain the PolyObject. Give this sector the same properties (floor height, ceiling height, flats and light level) as the sector in which you placed the spawn point. Inside that sector, draw the PolyObject itself so that all linedefs face outwards. The sector that they enclose will be called the PolyObject sector from now on. Its floor and ceiling height set the floor and ceiling height of the PolyObject. Each linedef's middle textures will be rendered as the PolyObject's textures on that side – the front middle texture is displayed on the outer side, while the back middle texture is displayed on the inner side. If the PolyObject has flats and is intended to always be solid and opaque, the inner sides will not be visible, so the back middle texture can be omitted. By default, the textures are drawn only once, even if they do not stretch to the full height of the PolyObject. To tile them until they fill the entire height of the PolyObject, check the Repeat Midtexture flag on every linedef.
Place a PolyObject Anchor somewhere within the PolyObject sector or the surrounding sector and set its Angle to the PolyObject's ID. When spawning the PolyObject, this is the point that overlaps with the spawn point. For rotating PolyObjects, this point is the axis that the PolyObject will rotate around. Give one linedef of the PolyObject linedef type 20 and an unused tag. This is the PolyObject's First Line; it is used to identify the PolyObject. Another control sector is needed to specify the parameters. Give one of its linedefs linedef type 22 and tag it to the PolyObject's First Line. Set the floor height of the control sector to the PolyObject's ID.
By default, PolyObjects will not display any flats. To enable them for a PolyObject, the Solid Midtexture flag should be checked on the PolyObject's First Line – the PolyObject sector's floor and ceiling flats will be set as the bottom and top flats of the PolyObject, respectively.
The following linedef types are used for PolyObject setup:
- Linedef type 20: First Line – Must be given to one of the PolyObject's linedefs for identification.
- Linedef type 21: Explicitly Include Line – Has no noticeable effect in the current version of SRB2.
- Linedef type 22: Parameters – Sets the parameters for a PolyObject.
- Linedef type 30: Waving Flag – Used to shift parts of the PolyObject back and forth, creating a waving effect.
- Linedef type 31: Displacement by Front Sector – Used to scroll a PolyObject in a particular direction, by changing the heights of the linedef's front sector.
The following Thing types are used for PolyObject setup:
- Thing type 760: PolyObject Anchor – Specifies the center of the PolyObject. For rotating PolyObjects, this is the rotation axis.
- Thing type 761: PolyObject Spawn Point – Specifies where the PolyObject Anchor will be spawned.
- Thing type 762: PolyObject Spawn Point (Crush) – Same as above, but makes the PolyObject able to crush players.
PolyObjects are able to perform actions through the use of linedef executors. SRB2 includes twelve types of linedef executors for PolyObjects, which allow them to move, rotate, disappear/reappear or change their translucency.
PolyObjects can trigger linedef executors just like regular sectors. To do this, give the desired trigger sector special to the PolyObject sector and tag it to a trigger linedef. If the Not Climbable flag is checked on the PolyObject's First Line, linedef executors can be triggered when a player explicitly lands on the PolyObject (as opposed to just standing on the PolyObject, or stepping up/down onto it from elsewhere). In this case, no sector special is needed – any trigger linedef with a tag of 32000 plus the PolyObject's ID will be triggered automatically.
The following actions can be performed by PolyObjects:
- Linedef type 480: Door Slide
- Linedef type 481: Door Swing
- Linedef type 482: Move
- Linedef type 483: Move, Override
- Linedef type 484: Rotate Right
- Linedef type 485: Rotate Right, Override
- Linedef type 486: Rotate Left
- Linedef type 487: Rotate Left, Override
- Linedef type 488: Move by Waypoints
- Linedef type 489: Turn Invisible, Intangible
- Linedef type 490: Turn Visible, Tangible
- Linedef type 491: Set Translucency
Certain linedef flags can be set on a PolyObject's First Line to control special settings:
- If the Slope Skew flag is set, only the outer sides of the PolyObject are rendered.
- If the No Midtexture Skew flag is set, the PolyObject will be intangible.
- If the Peg Midtexture flag is set, the PolyObject will stop any movement if it comes in contact with a pushable Object.
- If the Solid Midtexture flag is set, the PolyObject's flats will be rendered.
- If the Not Climbable flag is set, the PolyObject will activate any trigger linedefs whose tag is 32000 plus the PolyObject's ID when a player lands on the PolyObject (as opposed to just standing on the PolyObject, or stepping up/down onto it from elsewhere).
Furthermore, the Repeat Midtexture can be set on each of the PolyObject's linedefs to tile the textures on that linedef to fill the entire height of the PolyObject. Otherwise, the textures are only displayed once and not tiled. If the Repeat Midtexture flag is set, it is also possible to specify an exact number of times that the texture should be repeated: For each repetition (in addition to the one time the texture is always drawn), 4096 must be added to the sidedef's X offset. For example, if the X offset is between 4096 and 8191, the texture is stacked twice, whereas if it is between 8192 and 12287, it is stacked three times. If the X offset is between 0 and 4095, the texture is tiled to fill the entire gap as described above.
Examples of PolyObjects in official levels
- Near the beginning of Techno Hill Zone Act 2 is a room where the player has to jump across platforms that are periodically obstructed by blocks that slide in and out of the walls. These blocks are implemented with PolyObjects that use the Move, Override effect. The movement is triggered once on level load with linedef type 399 and is then periodically repeated with the use of linedef type 450 and a timing effect.
- The elevator at the end of Techno Hill Zone Act 2 has two sliding doors that use the Move effect to close and open.
- The gates before the castle at the end of Castle Eggman Zone Act 1 are PolyObjects that use the Rotate Right, Override and Rotate Left, Override effects to open.
- The cannonball room in Castle Eggman Zone Act 2 features two waving flags.
- As part of a secret, Castle Eggman Zone Act 2 features a bookcase that can be pushed open to reveal a hidden passage. The setup is complicated but mostly revolves around a continuous trigger coupled with a Rotate Left effect, which creates the illusion that the PolyObject is being pushed.
- Arid Canyon Zone Act 1 features a chair lift that transports the player across a pit when stepped on. The trigger is set up with the Not Climbable flag, while the movement action is Door Slide.
- As part of a secret, Arid Canyon Zone Act 1 features a crate that can be pushed into an machine that drains a pool of oil, revealing a hidden passage underneath. Upon being touched, the Move effect is used to slide the crate. Because the crate only moves a short distance, the illusion that the player is pushing it is upheld even though it moves by itself.
- At the beginning of Egg Rock Zone Act 2, the player has the choice between two rooms that both contain a button that opens the door to the rest of the level. The room to the right contains two sliding panels that the player has to navigate. These panels are PolyObjects that move with the Move by Waypoints effect, triggered on level load. The room to the left features five fans that the player has to navigate over. The visual effect for the fans is provided by rotating PolyObjects.
- At the beginning of the left path of Egg Rock Zone Act 2 is an outdoor room in which the player has to press a sideways button to open a door. Both the button and the door are PolyObjects that function like the oil draining machine in ACZ1 and the door in THZ2, respectively.
- On the left path of Egg Rock Zone Act 2 is a room with a large door that periodically opens and sucks players into space. Before the player can enter the room, the effect is demonstrated with three crates that are sucked into space. These crates are PolyObjects that move with the Move by Waypoints effect.
- Right after the space suction room, there is a small room with several crushers, some of which are sideways. The right path contains a section with sideways crushers as well. These crushers are PolyObjects that move with the Move by Waypoints effect, triggered on level load.
- Near the end of Egg Rock Zone Act 2, the player has to pass two rotating gears. These gears are made up of rotating, crushing PolyObjects. Since the gears as a whole would be concave, each cog is a separate PolyObject.
- The laser miniboss at the end of Egg Rock Zone Act 2 is a PolyObject that uses the Move by Waypoints effect and a complicated linedef executor setup to chase the player.
PolyObjects can be linked to each other by associating a "parent" PolyObject with one or several "child" PolyObjects. This means that whenever a "parent" PolyObject is made to move or rotate, its "child" PolyObjects will automatically perform the same actions. This does not apply to the non-movement actions of linedef types 489, 490 or 491.
To set up a PolyObject as a child of another, in addition to the normal setup, the control sector of the PolyObject's Parameters linedef should have its sector special value set to the PolyObject ID of the PolyObject to designate as its parent. Parent PolyObjects themselves can be set up as normal.
This feature is not currently used in any official level in SRB2 v2.1.