phys_magnet
![Phys magnet.png](/w/images/7/7b/Phys_magnet.png)
![]() |
---|
CPhysMagnet defined in ![]() physobj.cpp
|
phys_magnet
is a point entity available in all Source games. It acts like a magnet, attaching metallic physics objects to itself when they touch it.
![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
memory could not be 'read'
error.![Icon-Bug.png](/w/images/thumb/b/b4/Icon-Bug.png/10px-Icon-Bug.png)
![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
phys_
entity, it uses a modelContents
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
d2_coast_01
to prevent objects from interfering with the crane as it picks up the buggy. It is hardcoded for use withprop_vehicle_jeep
only.
![Note.png](/w/images/thumb/c/cc/Note.png/10px-Note.png)
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.