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

Phys magnet: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Please format)
 
m (Classifying as model entity)
 
(32 intermediate revisions by 17 users not shown)
Line 1: Line 1:
phys_magnet
[[File:phys_magnet.png|left|link=]]
{{CD|CPhysMagnet|file1=physobj.cpp}}
{{this is a|model entity|name=phys_magnet}} It acts like a magnet, attaching metallic physics objects to itself when they touch it.
{{warning|If a prop model is not specified for this entity, the map will crash with a <code>memory could not be 'read'</code> error.}}
{{bug|Removing this entity without removing crane can cause crashes.}}
{{ModernConfusion|This is not a typical <code>phys_</code> entity, it uses a model}}
{{clr}}


An entity that acts like a magnet, attaching metallic physics objects to itself when they touch it.
== Keyvalues ==
{{KV Targetname}}
{{KV|Force Limit to Break (lbs)|intn=forcelimit|float|The amount of force necessary to break a stuck object off the magnet. A way of calculating this is to set it to the mass of an object that would break this constraint if it were resting on the magnet.}}
{{KV|Torque Limit to Break (lbs*inches)|intn=torquelimit|float|The amount of torque necessary to break a stuck object off the magnet. A way of calculating this is to multiply any reference mass by the resting distance (from the center of mass of the object) needed to break the constraint.}}
{{KV|Mass Scale|intn=massScale|float|A scale multiplier for the object's mass.}}
{{KV|Override parameters|intn=overridescript|string|A list of physics key/value pairs that are usually in a physics prop [[QC|.qc file]]. Format is 'key,value,key,value,etc'.}}
{{KV|Maximum Attached Objects|intn=maxobjects|integer|The maximum number of physics objects that can be stuck to the magnet at once. 0 {{=}} no limit.}}


KEYS
== Flags ==
* 1 : Start Asleep
* 2 : Motion Disabled
* 4 : Suck On Touch
* 8 : Allow Attached Rotation
* 16 : Coast jeep pickup hack - Used on {{hl2}}{{ent|d2_coast_01}} to prevent objects from interfering with the crane as it picks up the buggy. It is hardcoded for use with {{ent|prop_vehicle_jeep}} only.
{{note|Another entity ''can'' be used by changing the entity's <code>classname</code> to {{ent|prop_vehicle_jeep}} using [[AddOutput]]. However, if the game is saved/reloaded or the round restarts in multiplayer, the entity will no longer function and will cause crashes.}}


Name targetname <target_source> The name that other entities refer to this entity by.
== Inputs ==
{{I|TurnOn|Turn the magnet on.}}
{{I|TurnOff|Turn the magnet off. This will detach anything current stuck to the magnet.}}
{{I|Toggle|Toggle the magnet on or off.}}


Parent parentname <target_destination> The name of this entity's parent in the movement hierarchy. Entities with parents move with their parent.
== Outputs ==
{{O|OnAttach|Fired when an entity is grabbed by the magnet.}}
{{O|OnDetach|Fired when an entity is released by the magnet.}}


Pitch Yaw Roll (Y Z X) 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.
== See also ==
* {{ent|prop_vehicle_crane}}


World Model model <studio>
[[Category:Forces]]
 
Skin skin <integer> Some models have multiple versions of their textures, called skins. Set this to a number other than 0 to use that skin instead of the default.
 
Disable Shadows disableshadows <choices> Used to disable dynamic shadows on this entity.
 
spawnflags spawnflags <flags>
 
Force Limit to Break (lbs) forcelimit <float> The amount of force necessary to break a stuck object off the magnet. A way of calculating this is to set it to the mass of an object that would break this constraint if it were resting on the magnet.
 
Torque Limit to Break (lbs * distance) torquelimit <float> The amount of torque necessary to break a stuck object off the magnet. A way of calculating this is to multiply any reference mass by the resting distance (from the center of mass of the object) needed to break the constraint.
 
Mass Scale massScale <float> A scale multiplier for the object's mass.
 
Override parameters overridescript <string> A list of physics key/value pairs that are usually in a physics prop .qc file. Format is 'key,value,key,value,etc'.
 
Maximum Attached Objects maxobjects <integer> The maximum number of physics objects that can be stuck to the magnet at once. 0 = no limit.
 
 
INPUTS
 
Kill Removes this entity from the world.
 
KillHierarchy Removes this entity and all its children from the world.
 
AddOutput <string> Adds an entity I/O connection to this entity. Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>. 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.
 
SetParent <string> Changes the entity's parent in the movement hierarchy.
 
SetParentAttachment <string> Change this entity to attach to a specific attachment point on its parent. Entities must be parented before being sent this input. The parameter passed in should be the name of the attachment.
 
ClearParent Removes this entity from the the movement hierarchy, leaving it free to move independently.
 
Skin <integer> Changes the model skin to the specified number.
 
DisableShadow Turn shadow off.
 
EnableShadow Turn shadow on.
 
TurnOn Turn the magnet on.
 
TurnOff The the magnet off. This will detach anything current stuck to the magnet.
 
 
OUTPUTS
 
OnUser1 Fired in response to FireUser1 input.
 
OnUser2 Fired in response to FireUser2 input.
 
OnUser3 Fired in response to FireUser3 input.
 
OnUser4 Fired in response to FireUser4 input.
 
OnIgnite Fired when this object catches fire.
 
OnAttach Fired when an entity is grabbed by the magnet.
 
OnDetach Fired when an entity is released by the magnet.

Latest revision as of 04:33, 19 May 2025

Phys magnet.png
C++ Class hierarchy
CPhysMagnet
CBaseAnimating
CBaseEntity
C++ physobj.cpp

phys_magnet is a model entity available in all Source Source games. It acts like a magnet, attaching metallic physics objects to itself when they touch it.

Warning.pngWarning:If a prop model is not specified for this entity, the map will crash with a memory could not be 'read' error.
Icon-Bug.pngBug:Removing this entity without removing crane can cause crashes.  [todo tested in ?]
Warning.pngRisk of Confusion:This is not a typical phys_ entity, it uses a model

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

Force Limit to Break (lbs) (forcelimit) <float>
The amount of force necessary to break a stuck object off the magnet. A way of calculating this is to set it to the mass of an object that would break this constraint if it were resting on the magnet.
Torque Limit to Break (lbs*inches) (torquelimit) <float>
The amount of torque necessary to break a stuck object off the magnet. A way of calculating this is to multiply any reference mass by the resting distance (from the center of mass of the object) needed to break the constraint.
Mass Scale (massScale) <float>
A scale multiplier for the object's mass.
Override parameters (overridescript) <string>
A list of physics key/value pairs that are usually in a physics prop .qc file. Format is 'key,value,key,value,etc'.
Maximum Attached Objects (maxobjects) <integer>
The maximum number of physics objects that can be stuck to the magnet at once. 0 = no limit.

Flags

  • 1 : Start Asleep
  • 2 : Motion Disabled
  • 4 : Suck On Touch
  • 8 : Allow Attached Rotation
  • 16 : Coast jeep pickup hack - Used on Half-Life 2d2_coast_01 to prevent objects from interfering with the crane as it picks up the buggy. It is hardcoded for use with prop_vehicle_jeep only.
Note.pngNote:Another entity can be used by changing the entity's classname to prop_vehicle_jeep using AddOutput. However, if the game is saved/reloaded or the round restarts in multiplayer, the entity will no longer function and will cause crashes.

Inputs

TurnOn
Turn the magnet on.
TurnOff
Turn the magnet off. This will detach anything current stuck to the magnet.
Toggle
Toggle the magnet on or off.

Outputs

OnAttach
Fired when an entity is grabbed by the magnet.
OnDetach
Fired when an entity is released by the magnet.

See also