Hanging things on ropes
Having an object hang by a realistically-moving rope gives players much more immersion than a rigid, stationary rope. This is often done with lamps to make them move around after being hit in some way.
Place whatever object you want on the rope at the spot it should come to rest at. Hypothetically you could use any physics object. All you need to do is give it a name. (This tutorial calls it lamp
.)
Create a rope with one end at the ceiling/wall, etc. (This tutorial calls it rope_anchor
.) The other end should be at the spot at which you want the rope to be attached to your hanging object. (This tutorial calls it rope_dangling
.) Parent rope_dangling
to lamp
. Obviously, set rope_anchor
's Next Keyframe to rope_dangling
. You can give your rope slack, but it might look weird. Ironically, you should leave Start Dangling on No.
Place a phys_lengthconstraint
at the exact same spot as rope_dangling
, or very close to it. In the 2D views, a white circle will appear once this entity is selected. Drag this circle up to the origin of rope_anchor
to set Attached object 2 point. Set Entity 1 to lamp
and leave Entity 2 blank. You can also use phys_spring
, which makes the movement a bit more realistic and has a basically identical setup, but requires more fiddling with it.
Run your map and you'll see the hanging object move away when nudged and shot at. You might also notice that it sways back and forth immediately after spawning, which is just draining CPU resources. Follow the regular process for settling the object with map_edit (and maybe turn up host_timescale). If it still jiggles slightly even after doing this, just set it to start asleep if the option is available.
Here's an example map with everything already set up for phys_lengthconstraint
and phys_spring
: [1] Note: This VMF was made at an earlier date when the logic_measure_movement
s were thought to be necessary. You can safely delete those!
Tip: A point_playermoveconstraint
can be used to physically slow the player as they try to pull farther than the rope allows.