material_modify_control

From Valve Developer Community
Jump to: navigation, search
English

Source material_modify_control is a point entity available in all Source games. It is used to modify arbitrary material properties in response to I/O events.

For the entity to work, its target material must have the MaterialModify or MaterialModifyAnimated proxy installed, and must be applied to an entity.

Compare this with the env_texturetoggle entity, which can control brushes or overlays by targetname.

Bug.png Bug: The entity will not work unless it's parented to an object that's in the PVS, is on-screen, and has at least one face facing towards the viewer that's textured with the Material to modify.

Instances of the Material to Modify on world geometry are controlled by the lowest-ID (first created in Hammer) material_modify_control, in addition to instances of the material on the material_modify_control's parent.

Keyvalues

Material to modify (materialName) <string>
Path to the VMT file you want to modify, relative to materials/ folder. Without .vmt suffix.
Bug.png Bug: Does not work if the VMT is just in materials/. Should be in a subfolder, like materials/effects/ for example.
Bug.png Bug: When a material has a $envmap with env_cubemap as the value, this entity will appear to not work for that material. This is because VBSP will patch the original material and give it a different name that corresponds to the position of the closest cubemap to the brush face that has that material. This happens for every occurrence of the material. In order to make it work, you can replace the env_cubemap in your material with the path to the generated image of the closest cubemap. For example: env_cubemap "maps/yourmap/c124_28_-60". This means, however, that you will have to do it for every occurrence of the material you want to change, especially when you want them to use different cubemap images. This will make it so that VBSP will not try to patch the material and thus leave the original name. Another way is to just to directly specify the patched material name that is generated by VBSP, which you can find after unpacking the map file.
Material variable to modify (materialVar) <string>
Name of the shader parameter you want to modify. Include the $ symbol like how they are written in the VMT.

Base:
Name (targetname) <string>
The name that other entities use to refer to this entity.
Parent (parentname) <targetname>
Maintain the same initial offset to this entity. An attachment point can also be used if separated by a comma at the end. (parentname [targetname],[attachment])
Tip.png Tip: Entities transition to the next map with their parents
Tip.png Tip: phys_constraintcan be used as a workaround if parenting fails.
Origin (X Y Z) (origin) <coordinates>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Note.png Note: Hammer does not move the entities accordingly only in the editor.
Pitch Yaw Roll (X Y Z) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note.png Note: This works on brush entities, although Hammer doesn't show the new angles.
Classname (classname) <string> !FGD
Determines the characteristics of the entity before it spawns.
Tip.png Tip: Changing this on runtime still has use, like making matching an entry in S_PreserveEnts will persist the entity on new rounds!
Flags (spawnflags) <integer> !FGD
Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
Effects (effects) <integer> !FGD
Combination of effect flags to use.
Entity Scripts (vscripts) <scriptlist> (in all games since Left 4 Dead 2)
Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
Thinker function (thinkfunction) <string> (in all games since Left 4 Dead 2)
Name of the function within this entity's script that'll be called automatically every 100 milliseconds, or a user-defined interval if the function returns a number. Avoid expensive operations in this function, as it may cause performance problems.
Lag Compensation (LagCompensate) <boolean> (in all games since Left 4 Dead 2) !FGD
Set to Yes to lag compensate this entity. Should be used very sparingly!
Is Automatic-Aim Target (is_autoaim_target) <boolean> (in all games since Counter-Strike: Global Offensive) !FGD
If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.


Inputs

SetMaterialVar <string>
Sets the chosen material parameter to the specified value.
SetMaterialVarToCurrentTime
This sets the material variable to the current time on the server.
StartAnimSequence <string>
Force an animated material with the MaterialModifyAnimated proxy to play a set of animation frames.
Format is: <Frame Start> <Frame End> <Frame Rate> <Loop>
<Loop> should be 1 or 0.
Tip.png Tip: Setting "Frame End" to -1 uses the last frame of the texture.
StartFloatLerp <string>
Force a material with the MaterialModifyAnimated proxy to linearly interpolate a material var between two floating point values.
Format is: <Start Value> <End Value> <Transition Time> <Loop>
<Loop> should be 1 or 0.
Note.png Note: For the linear interpolation to work correctly, you need both the MaterialModify and MaterialModifyAnimated proxies to be present.

To do: There are some clarifications needed to be done about some quirks of this input.


Base:
AddContext <string>
Adds to the entity's list of response contexts. Format is <key>:<value>.
AddOutput <string>
Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed:
Syntax: 
// Format of changing KeyValues: "AddOutput [key] [value]"
//// Raw text:
"OnUser1" "!self,AddOutput,targetname new_name"

// Format of adding an Output: "AddOutput {targetname}:{inputname}:{parameter}:{delay}:{max times to fire, -1 means infinite}"
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:SetParent:!activator:0.0:-1"
// Arguments can be left blank, but the empty blank should still be contained.
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:ClearParent::0.0:-1"
ClearContext
Removes all contexts from this entity's list.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.
FireUser1 to FireUser4
Fires the respectiveOnUseroutputs; see User Inputs and Outputs.
Kill
Removes this entity and any entities parented to it from the world.
KillHierarchy
Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKillinput.
RemoveContext <string>
Remove a context from this entity's list. The name should match the key of an existing context.
SetParent <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Use  !FGD
Same as a player invoking +use; no effect in most cases.
DispatchResponse <string> !FGD
Dispatches a response to the entity. See Response and Concept.
DispatchEffect <string> (removed since Left 4 Dead) !FGD
Dispatches a special effect from the entity's origin; see also List of Client Effects. Replaced by the particle system since Left 4 Dead.
RunScriptFile <script> (in all games since Left 4 Dead 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <string> (in all games since Left 4 Dead 2)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Bug.png Bug: In Hammer, using string arguments will corrupt the VMF file's structure, making the file unviewable for the next Hammer session.
Fix: Remove the string argument manually with a text editor.
CallScriptFunction <string> (in all games since Left 4 Dead 2) !FGD
Calls a VScript function defined in the scope of the receiving entity.
SetLocalOrigin <coordinates> (in all games since Alien Swarm) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles <angles> (in all games since Alien Swarm) !FGD
Set this entity's angles.

Outputs


Targetname:
OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  (only in Left 4 Dead series)
This output fires when the entity is killed and removed from the game.