phys_magnet

From Source Entities
Jump to navigation Jump to search

Code classes:

phys_magnet is a point entity present in all Source games. It acts like a magnet. Objects with the material types M and P (metal and computer) will get attached to the magnet if they touch it.

Bug: Magnets and objects affected by them may move extremely weirdly when carried by the Hl2.pnggravity gun.

Bug: The magnet does not check what's touching it when the TurnOn input is sent, so if it's touching something as it's turned on, that object will not stick until a new touchlink is created.

Flags[edit | edit source]

  • 1: Start Asleep - Magnet will not move until a force acts on it.
  • 2: Motion Disabled - Magnet never moves.
  • 4: Suck On Touch - Magnet tries to pull objects in. Attraction distance appears to be stuck at 80 units. Bug: Sometimes does not work, or repels depending on angles of objects?
  • 16: Coast jeep pickup hack - Makes the magnet only pick up prop_vehicle_jeeps, and break or delete anything else it touches. This flag was used on Hl2.pngd2_coast_01 to prevent the crane sequence from being broken by objects placed on top of the buggy.

Keyvalues[edit | edit source]

Force Limit to Break (lbs) (forcelimit) <float>
The amount of force that must be applied to make an object escape the magnet's pull.
Torque Limit to Break (lbs * distance) (torquelimit) <float>
The amount of torque that must be applied to make an object escape the magnet's pull.
Mass Scale (massscale) <float>
Multiplier for the magnet's mass.
Override Parameters (overridescript) <string>
A list of physics keyvalues that are usually embedded in the model. Format is key,value,key,value,....
Maximum Attached Objects (maxobjects) <integer>
The maximum number of physics objects that can be stuck to the magnet at once. 0 = no limit.

Inputs[edit | edit source]

TurnOn
Turns the magnet on.
TurnOff
Turns the magnet off (detaches any objects).
Toggle (Not in FGD)
If on, turn off. If off, turn on.

Outputs[edit | edit source]

OnAttach
Fires when something gets attached to the magnet.
OnDetach
Fires when something breaks free from the magnet naturally (not due to the magnet turning off).

See Also[edit | edit source]