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

phys_magnet

From Valve Developer Community
Jump to: navigation, search
Phys magnet.png
class hierarchy
CPhysMagnet defined in physobj.cpp
CBaseAnimating
CBaseEntity

phys_magnet is a point 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.
Warning.pngRisk of Confusion:This is not a typical phys_ entity, it uses a model

Keyvalues

Name (targetname) <string>
The targetname that other entities refer to this entity by.
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
The the magnet off. This will detach anything current stuck to the magnet.

Outputs

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

See also