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
m (Technical limitations)
No edit summary
 
(39 intermediate revisions by 19 users not shown)
Line 1: Line 1:
{{wrongtitle|title=logic_measure_movement}}
{{Underlinked|date=January 2024}}
{{LanguageBar}} {{Source topicon}}
{{CD|CLogicMeasureMovement|file1=logic_measure_movement.cpp}}


==Entity Description==
{{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 Name:''' logic_measure_movement


An entity that can measure the movement of an entity relative to another entity and apply that movement to a third entity.
logic_measure_movement's process can be described like this:


==Entity Values==
# The position of the ''Entity to Measure'' is obtained. Let's say it's <code>[100 225 0]</code>.
===Keys===
# The position of the ''Measure Reference'' is obtained. Let's say it's <code>[50 300 0]</code>.
# 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>.
# The position of the ''Movement Reference'' is obtained. Let's say it's <code>[150 50 100]</code>.
# 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 ''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>.


* '''Name''' ''targetname <target_source>''
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}}.
** The name that other entities refer to this entity by.
* '''Entity to Measure''' ''MeasureTarget <target_destination>''
** Entity whose movement you want to measure.
* '''Measure Reference''' ''MeasureReference <target_destination>''
** The movement of Entity to Measure will be measured relative to this entity.
* '''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.


{{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.}}


===Inputs===
== Keyvalues ==
{{KV Targetname}}
{{KV|Entity to Measure|intn=MeasureTarget|target_destination|Entity whose movement you want to measure.}}
{{KV|Measure Reference|intn=MeasureReference|target_destination|The movement of Entity to Measure will be measured relative to this entity.}}
{{KV|Entity to Move|intn=Target|target_destination|This entity will be moved to mimic the motions of Entity to Measure.}}
{{KV|Movement Reference|intn=TargetReference|target_destination|The Entity to Move will move relative to this entity.}}
{{KV|Movement scale|intn=TargetScale|float|
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.
}}
{{KV|Measurement Type|intn=MeasureType|choices|What to measure.}}
:* 0 : Position
:* 1 : Eye position


* '''Kill'''
== Inputs ==
** Removes this entity from the world.
{{note|Following inputs don't support <kbd>!activator/!caller/!self</kbd> as parameters}}
* '''KillHierarchy''' 
** Removes this entity and all its children from the world.
* '''AddOutput''' ''<output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>''
** Adds an entity I/O connection to this entity. Very dangerous, use with care
* '''FireUser1'''
** Causes this entity's OnUser1 output to be fired.
* '''FireUser2'''
** Causes this entity's OnUser2 output to be fired.
* '''FireUser3'''
** Causes this entity's OnUser3 output to be fired.
* '''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.


 
{{I|SetMeasureTarget|Set the Entity to Measure, whose movement should be measured.|param=string}}
===Outputs===
{{I|SetMeasureReference|Set the Measure Reference entity.|param=string}}
 
{{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.}}
* '''OnUser1'''
{{I|SetTarget|Set the Entity to Move, which will be moved to mimic the measured entity.|param=string|nofgd=1}}
** Fired in response to FireUser1 input.
{{I|SetTargetReference|Set the Movement Reference entity.|param=string}}
* '''OnUser2'''
{{I|SetTargetScale|Set the scale to divide the measured movements by.|param=float}}
** Fired in response to FireUser2 input.
{{I|Enable|Enable the logic_measure_movement.}}
* '''OnUser3'''
{{I|Disable|Disable the logic_measure_movement.}}
** Fired in response to FireUser3 input.
* '''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.