Func breakable surf: Difference between revisions
JensTrolldom (talk | contribs) No edit summary |
SirYodaJedi (talk | contribs) |
||
(52 intermediate revisions by 22 users not shown) | |||
Line 1: | Line 1: | ||
[[File:breakable_surf.jpg|thumb| | {{LanguageBar}} | ||
[[File:breakable_surf.jpg|thumb|A partially broken surface.]] | |||
{{CD|CBreakableSurface|file1=func_breakablesurf.cpp|base=CBreakable}} | |||
{{this is a|brush entity|name=func_breakable_surf|engine=Source}} | |||
It defines a breakable surface, for partially breakable glass/tile/etc. All faces that are not ever visible to the player should use [[nodraw]]. Faces that will be broken must have exactly four sides. The material applied to the visible face must be set up to be breakable. This entity is functionally similar to real-life tempered glass. | |||
{{ | The following standard textures are meant to work with this entity (using any other may crash the game on startup!): | ||
*{{code|glass/glasswindowbreak070a}} (but ''not'' {{code|glass/glasswindowbreak070b}}!) | |||
*{{code|tile/tilebreak001c}} (using this will stretch the texture if broken) | |||
*{{code|glass/urban_glass_3}} {{only|{{csgo}}}} | |||
= | {{expand|title=List of standard textures from {{bms|4}}:| | ||
*{{code|glass/glasswindowbreak070a}} | |||
{{ | *{{code|glass/labglass_c2a4_1windowbreak070a}} | ||
*{{code|lab/labglasswindowbreak070a}} | |||
*{{code|lab/labglass2windowbreak070a}} | |||
*{{code|glass/labglass_c2a4_2windowbreak070a}} | |||
}} | |||
Info for creating a material compatible with func_breakable_surf can be found [[Making a custom breakable surface|here]] | |||
{{bug| | {{bug|The entity must have its origin at <code>0 0 0</code>, otherwise the surface will disappear or become misplaced when damaged. With default [[FGD]]s this is a non-issue as the entity lacks an origin keyvalue entirely, but some custom FGDs add one, likely being unaware of this bug. If the entity appears with an origin keyvalue in Hammer, make sure to always set it to <code>0 0 0</code> after moving, rotating, or scaling the entity in order for it to behave correctly.|hidetested=1}} | ||
{{bug| | :{{confirm|By extension, the entity probably also breaks if parented.}} | ||
{{bug|The break sound will play from both the entity and the origin of the map (0,0,0), if this entity is placed on the boundary of the default [[visleaf]] cuts (indicated by blue lines in [[Hammer]] 2D view).|tested={{bms}}}} | |||
{{bug|hidetested=1|This entity ''is'' available and functional in {{tf2|4}}, although without the ability to break the glass with bullets (unlike in {{csgo|4}}, {{hl2|4}} and other source games). | |||
{{workaround|Assign this [[VScript]] code as an Entity Script on the entity to fix bullet damage not functioning. | |||
{{expand| | |||
<source lang=js> | |||
self.ConnectOutput("OnBreak", "OnBreak"); | |||
function OnBreak() | |||
{ | |||
self.RemoveSolidFlags(Constants.FSolid.FSOLID_NOT_SOLID); | |||
self.SetCollisionGroup(27); // TFCOLLISION_GROUP_ROCKET_BUT_NOT_WITH_OTHER_ROCKETS | |||
} | |||
</source> | |||
}}}}}} | |||
{{bug|hidetested=1|Weapons from {{bms|4}} with muzzle dynamic lights can "illuminate" this entity if damaged, even if player's position is far from actual position of the entity. | |||
{{ | |||
== | You can partially workaround it by making crack texture pretty mute/dark (because the lighting is displayed ONLY on the [[lightmap]]). | ||
{{expand|title=Example.| | |||
<gallery mode=packed heights=450px> | |||
File:cAnSexample.gif| frame | | |||
</gallery> | |||
}} | |||
}} | |||
{{bug|You can place portals on the back of an unbroken breakable surf regardless of if [[SURF_NOPORTAL]] is present.|tested={{portal}}}} | |||
{{ | |||
{{ | |||
== Outputs == | __NOTOC__ | ||
{{O | |||
==Flags== | |||
{{fl|1|Physics damage decals}} | |||
{{fl|2|Take damage from held objects}} | |||
{{fl|4|Break on Pressure}} | |||
{{fl|512|Break immediately on Physics}} | |||
{{fl|1024|Don't take physics damage}} | |||
{{fl|2048|Don't allow bullet penetration}} | |||
==Keyvalues== | |||
{{KV Targetname}} | |||
{{KV|Fragility|intn=fragility|integer|If the 'Surface Type' is set to Glass, this value sets how fragile the glass pieces are after the surface has been broken.}} | |||
{{KV|Surface Type|intn=surfacetype|choices|Surface material type | |||
:*0: Glass | |||
:*1: Tile}} | |||
{{bug|Using Tile as the Surface Type will show missing textures and make the whole surface non-solid when damaged.|tested={{bms}}}} | |||
{{KV|Face Error|intn=error|integer choices|Set automatically by Hammer when saving to indicate an invalid glass/tile surface, when non-zero the entity will be removed when spawned, and a error message will be thrown in the console. This keyvalue is not included in Valve's FGDs, but is still fully functional. | |||
:*0: No Error | |||
:*1: Multiple Textured Faces | |||
::{{bug|tested={{hammer4}}|Hammer only treats {{code|tools/toolsnodraw}} as being "untextured", and will throw this error if any other custom [[nodraw]] texture is used!}} | |||
:*2: Non-Square Face | |||
|nofgd=1}} | |||
{{KV|nofgd=1|Lower Left Corner|intn=lowerleft|vec3|This is set automatically by Hammer when saving. Specifies the coordinates of the lower left corner.}} | |||
{{KV|nofgd=1|Lower Right Corner|intn=lowerright|vec3|This is set automatically by Hammer when saving. Specifies the coordinates of the lower right corner.}} | |||
{{KV|nofgd=1|Upper Left Corner|intn=upperleft|vec3|This is set automatically by Hammer when saving. Specifies the coordinates of the upper left corner.}} | |||
{{KV|nofgd=1|Upper Right Corner|intn=upperright|vec3|This is set automatically by Hammer when saving. Specifies the coordinates of the upper right corner.}} | |||
{{Expand|title=BreakableBrush|{{KV BreakableBrush}}}} | |||
==Inputs== | |||
{{I|Shatter|param=vec3|Shatter the window. Input a vector. First two coordinates are the X,Y center of the shattering (as values from 0-1). The third coordinate is the radius of the shatter, in hammer units.}} | |||
{{Expand|title=BreakableBrush|{{I BreakableBrush}}}} | |||
==Outputs== | |||
{{O Breakable}} | |||
==See also== | ==See also== | ||
* | * {{ent|func_breakable}} | ||
* [[Breakable Glass]] - How to create breakable glass. | * [[Breakable Glass]] - How to create breakable glass. | ||
* [[Glass that starts out broken]] - Making glass | * [[Glass that starts out broken]] - Making glass spawn broken. |
Latest revision as of 11:09, 4 June 2025


![]() |
---|
CBreakableSurface |
![]() |
func_breakable_surf
is a brush entity available in all Source games.
It defines a breakable surface, for partially breakable glass/tile/etc. All faces that are not ever visible to the player should use nodraw. Faces that will be broken must have exactly four sides. The material applied to the visible face must be set up to be breakable. This entity is functionally similar to real-life tempered glass.
The following standard textures are meant to work with this entity (using any other may crash the game on startup!):
- glass/glasswindowbreak070a (but not glass/glasswindowbreak070b!)
- tile/tilebreak001c (using this will stretch the texture if broken)
- glass/urban_glass_3 (only in
)
|
Info for creating a material compatible with func_breakable_surf can be found here

0 0 0
, otherwise the surface will disappear or become misplaced when damaged. With default FGDs this is a non-issue as the entity lacks an origin keyvalue entirely, but some custom FGDs add one, likely being unaware of this bug. If the entity appears with an origin keyvalue in Hammer, make sure to always set it to 0 0 0
after moving, rotating, or scaling the entity in order for it to behave correctly.Confirm:By extension, the entity probably also breaks if parented.





self.ConnectOutput("OnBreak", "OnBreak");
function OnBreak()
{
self.RemoveSolidFlags(Constants.FSolid.FSOLID_NOT_SOLID);
self.SetCollisionGroup(27); // TFCOLLISION_GROUP_ROCKET_BUT_NOT_WITH_OTHER_ROCKETS
}
|


You can partially workaround it by making crack texture pretty mute/dark (because the lighting is displayed ONLY on the lightmap).
|


Flags
- Physics damage decals : [1]
- Take damage from held objects : [2]
- Break on Pressure : [4]
- Break immediately on Physics : [512]
- Don't take physics damage : [1024]
- Don't allow bullet penetration : [2048]
Keyvalues
- Name (targetname) <string>[ Edit ]
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentname
ortarget
).
Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
- Fragility (fragility) <integer>
- If the 'Surface Type' is set to Glass, this value sets how fragile the glass pieces are after the surface has been broken.
- Surface Type (surfacetype) <choices>
- Surface material type
- 0: Glass
- 1: Tile
- Face Error (error) <integer choices> !FGD
- Set automatically by Hammer when saving to indicate an invalid glass/tile surface, when non-zero the entity will be removed when spawned, and a error message will be thrown in the console. This keyvalue is not included in Valve's FGDs, but is still fully functional.
- 0: No Error
- 1: Multiple Textured Faces
Bug:Hammer only treats tools/toolsnodraw as being "untextured", and will throw this error if any other custom nodraw texture is used! (tested in:
)
- 2: Non-Square Face
- Lower Left Corner (lowerleft) <vector3> !FGD
- This is set automatically by Hammer when saving. Specifies the coordinates of the lower left corner.
- Lower Right Corner (lowerright) <vector3> !FGD
- This is set automatically by Hammer when saving. Specifies the coordinates of the lower right corner.
- Upper Left Corner (upperleft) <vector3> !FGD
- This is set automatically by Hammer when saving. Specifies the coordinates of the upper left corner.
- Upper Right Corner (upperright) <vector3> !FGD
- This is set automatically by Hammer when saving. Specifies the coordinates of the upper right corner.
Breakable (brush):
Breakable (common):
|
Inputs
- Shatter <vector3>
- Shatter the window. Input a vector. First two coordinates are the X,Y center of the shattering (as values from 0-1). The third coordinate is the radius of the shatter, in hammer units.
BreakableBrush:
|
Outputs
BreakableBrush:
- OnBreak
- !activator = entity that breaks the object
!caller = this entity
Fired when this object breaks.
- OnHealthChanged <float >
- !activator = entity that caused the health change
!caller = this entity
Fired whenever the health of the breakable has increased or decreased. This output automatically puts the new health amount as a decimal percent (e.g. 45% = 0.45) into the parameter box for inputs, if the mapper does not override the parameter with something else.
See also
- func_breakable
- Breakable Glass - How to create breakable glass.
- Glass that starts out broken - Making glass spawn broken.