This article's documentation is for anything that uses the Source engine. Click here for more information.

Logic measure movement: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(40 intermediate revisions by 20 users not shown)
Line 1: Line 1:
==Entity Description==
{{Underlinked|date=January 2024}}
'''Entity Name:''' logic_measure_movement
{{LanguageBar}} {{Source topicon}}
{{CD|CLogicMeasureMovement|file1=logic_measure_movement.cpp}}


An entity that can measure the movement of an entity relative to another entity and apply that movement to a third entity.
{{this is a|logical entity|name=logic_measure_movement}} This entity measures the movement of an entity relative to another entity and then applies that movement to a third entity.


==Entity Values==
logic_measure_movement's process can be described like this:
===Keys===


* '''Name''' ''targetname <target_source>''
# The position of the ''Entity to Measure'' is obtained. Let's say it's <code>[100 225 0]</code>.
** The name that other entities refer to this entity by.
# The position of the ''Measure Reference'' is obtained. Let's say it's <code>[50 300 0]</code>.
* '''Entity to Measure''' ''MeasureTarget <target_destination>''
# The position of the ''Entity to Measure'' is subtracted by the position of the ''Measure Reference'', creating a "relative position" difference. In this case, it would be <code>[100 225 0]</code> - <code>[50 300 0]</code>, which equates to <code>[50 -75 0]</code>.
** Entity whose movement you want to measure.
# The position of the ''Movement Reference'' is obtained. Let's say it's <code>[150 50 100]</code>.
* '''Measure Reference''' ''MeasureReference <target_destination>''
# The "relative difference" position is added onto the position of the ''Movement Reference''. In this case, it would be <code>[50 -75 0]</code> + <code>[150 50 100]</code>, which equates to <code>[200 -25 100]</code>.
** The movement of Entity to Measure will be measured relative to this entity.
# The ''Entity to Move'' is teleported to the sum of the "relative difference" position and the position of the ''Movement Reference'', which in this case means the entity is teleported to <code>[200 -25 100]</code>.
* '''Entity to Move''' ''Target <target_destination>''
** This entity will be moved to mimic the motions of Entity to Measure.
* '''Movement Reference''' ''TargetReference <target_destination>''
** The Entity to Move will move relative to this entity.
* '''Movement scale''' ''TargetScale <float>''
** A scale to divide the measured movements by, before applying those movements to the Entity to Move. 1 = target entity moves as much as the measured entity, 2 = target entity moves half as far as the measured entity, and 0.5 = target entity moves twice as far as the measured entity.
* '''Measurement Type''' ''MeasureType <choices>''
** What to measure.  If '''Position''', measures the entity's linear movement; if '''Eye Position''', measures the entity's angular movement.


logic_measure_movement is very flexible and can be used to make one entity mimic the movement of another from another room (e.g. a {{ent|point_camera}} in a script_intro). It can also be used to serve as an alternative to parenting, especially since it can simulate parenting on physics objects, which don't support parenting and would normally use {{ent|phys_constraint}}.


===Inputs===
{{warning|Does not properly update collision physics on the object being moved.}}
{{Codenote|By default, logic_measure_movement calls {{Code|[[GetAbsOrigin()|SetAbsOrigin]]}} directly. Using {{Code|Teleport}} instead updates [[Source Multiplayer Networking#Entity interpolation|entity interpolation]] correctly and may or may not solve the collision physics warning described above.}}


* '''Kill'''
== Keyvalues ==
** Removes this entity from the world.
{{KV Targetname}}
* '''KillHierarchy''' 
{{KV|Entity to Measure|intn=MeasureTarget|target_destination|Entity whose movement you want to measure.}}
** Removes this entity and all its children from the world.
{{KV|Measure Reference|intn=MeasureReference|target_destination|The movement of Entity to Measure will be measured relative to this entity.}}
* '''AddOutput''' ''<output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>''
{{KV|Entity to Move|intn=Target|target_destination|This entity will be moved to mimic the motions of Entity to Measure.}}
** Adds an entity I/O connection to this entity. Very dangerous, use with care
{{KV|Movement Reference|intn=TargetReference|target_destination|The Entity to Move will move relative to this entity.}}
* '''FireUser1'''
{{KV|Movement scale|intn=TargetScale|float|
** Causes this entity's OnUser1 output to be fired.
A scale to divide the measured movements by, before applying those movements to the Entity to Move. <br/> 1 {{=}} target entity moves as much as the measured entity, <br/> 2 {{=}} target entity moves half as far as the measured entity, and <br/> 0.5 {{=}} target entity moves twice as far as the measured entity.
* '''FireUser2'''
}}
** Causes this entity's OnUser2 output to be fired.
{{KV|Measurement Type|intn=MeasureType|choices|What to measure.}}
* '''FireUser3'''
:* 0 : Position
** Causes this entity's OnUser3 output to be fired.
:* 1 : Eye position
* '''FireUser4'''
** Causes this entity's OnUser4 output to be fired.
* '''SetMeasureTarget <string>'''
** Set the Entity to Measure, whose movement should be measured.
* '''SetMeasureReference <string>'''
** Set the Measure Reference entity.
* '''Target <string>'''
** Set the Entity to Move, which will be moved to mimic the measured entity.
* '''SetTargetReference <string>'''
** Set the Movement Reference entity.
* '''SetTargetScale <float>'''
** Set the scale to divide the measured movements by.
* '''Enable'''
** Enable the logic_measure_movement.
* '''Disable'''
** Disable the logic_measure_movement.


== Inputs ==
{{note|Following inputs don't support <kbd>!activator/!caller/!self</kbd> as parameters}}


===Outputs===
{{I|SetMeasureTarget|Set the Entity to Measure, whose movement should be measured.|param=string}}
 
{{I|SetMeasureReference|Set the Measure Reference entity.|param=string}}
* '''OnUser1'''
{{I|<s>Target</s>|<s>Set the Entity to Move, which will be moved to mimic the measured entity.</s>|param=string}}{{note|This input does not exist in code, only in the FGD. Use <tt>SetTarget</tt> instead.}}
** Fired in response to FireUser1 input.
{{I|SetTarget|Set the Entity to Move, which will be moved to mimic the measured entity.|param=string|nofgd=1}}
* '''OnUser2'''
{{I|SetTargetReference|Set the Movement Reference entity.|param=string}}
** Fired in response to FireUser2 input.
{{I|SetTargetScale|Set the scale to divide the measured movements by.|param=float}}
* '''OnUser3'''
{{I|Enable|Enable the logic_measure_movement.}}
** Fired in response to FireUser3 input.
{{I|Disable|Disable the logic_measure_movement.}}
* '''OnUser4'''
** Fired in response to FireUser4 input.
 
 
==Additional Info==
* Useful for simulating motion outside of the hierarchy system.

Latest revision as of 04:55, 29 April 2025

Underlinked - Logo.png
This article needs more Wikipedia icon links to other articles to help Wikipedia icon integrate it into the encyclopedia. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
English (en)Translate (Translate)
C++ Class hierarchy
CLogicMeasureMovement
CLogicalEntity
CServerOnlyEntity
CBaseEntity
C++ logic_measure_movement.cpp

logic_measure_movement is a logical entity available in all Source Source games. This entity measures the movement of an entity relative to another entity and then applies that movement to a third entity.

logic_measure_movement's process can be described like this:

  1. The position of the Entity to Measure is obtained. Let's say it's [100 225 0].
  2. The position of the Measure Reference is obtained. Let's say it's [50 300 0].
  3. The position of the Entity to Measure is subtracted by the position of the Measure Reference, creating a "relative position" difference. In this case, it would be [100 225 0] - [50 300 0], which equates to [50 -75 0].
  4. The position of the Movement Reference is obtained. Let's say it's [150 50 100].
  5. The "relative difference" position is added onto the position of the Movement Reference. In this case, it would be [50 -75 0] + [150 50 100], which equates to [200 -25 100].
  6. The Entity to Move is teleported to the sum of the "relative difference" position and the position of the Movement Reference, which in this case means the entity is teleported to [200 -25 100].

logic_measure_movement is very flexible and can be used to make one entity mimic the movement of another from another room (e.g. a point_camera in a script_intro). It can also be used to serve as an alternative to parenting, especially since it can simulate parenting on physics objects, which don't support parenting and would normally use phys_constraint.

Warning.pngWarning:Does not properly update collision physics on the object being moved.
Cpp.pngCode:By default, logic_measure_movement calls SetAbsOrigin directly. Using Teleport instead updates entity interpolation correctly and may or may not solve the collision physics warning described above.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Entity to Measure (MeasureTarget) <targetname>
Entity whose movement you want to measure.
Measure Reference (MeasureReference) <targetname>
The movement of Entity to Measure will be measured relative to this entity.
Entity to Move (Target) <targetname>
This entity will be moved to mimic the motions of Entity to Measure.
Movement Reference (TargetReference) <targetname>
The Entity to Move will move relative to this entity.
Movement scale (TargetScale) <float>
A scale to divide the measured movements by, before applying those movements to the Entity to Move.
1 = target entity moves as much as the measured entity,
2 = target entity moves half as far as the measured entity, and
0.5 = target entity moves twice as far as the measured entity.
Measurement Type (MeasureType) <choices>
What to measure.
  • 0 : Position
  • 1 : Eye position

Inputs

Note.pngNote:Following inputs don't support !activator/!caller/!self as parameters


SetMeasureTarget <stringRedirectInput/string>
Set the Entity to Measure, whose movement should be measured.
SetMeasureReference <stringRedirectInput/string>
Set the Measure Reference entity.
Target <stringRedirectInput/string>
Set the Entity to Move, which will be moved to mimic the measured entity.
Note.pngNote:This input does not exist in code, only in the FGD. Use SetTarget instead.
SetTarget <stringRedirectInput/string> !FGD
Set the Entity to Move, which will be moved to mimic the measured entity.
SetTargetReference <stringRedirectInput/string>
Set the Movement Reference entity.
SetTargetScale <floatRedirectInput/float>
Set the scale to divide the measured movements by.
Enable
Enable the logic_measure_movement.
Disable
Disable the logic_measure_movement.