How do I make a detachable plug with socket?

I would like to be able to pick up a plug with E, carry it over to a socket and have it attach to the socket like in the Half Life series.

There used to be a tutorial up on Halfwit, but the website has been down for weeks.
I’ve looked at some of Valve’s levels to see how they did it, but I can’t seem to break it down myself.

Can anyone help please? There seriously is no help online for this.

prop_physics, name it, have a trigger teleport with a filter set to it, have it teleported to an info position and also disable motion on it at the same time.

Fantastic! Thanks dude! Would an info_target work as well?

For extra information, you could go ahead and decompile one of the HL2 maps using BSPSource to find out how it works.

Sorry I was lazy earlier.

First you’ll want a prop_physics set to the plug model and a prop_dynamic/prop_static set to the socket model. Place the socket where you want it, then place the plug in it. Copy this plug somewhere else, then make the one that is plugged in into an info_target. This way it will align correctly when teleported.

Make a trigger_teleport and set it to the info_target, set the filter to whatever you named the prop_physics.

Add an output that

ontrigger nameoftheprop disablemotion

to prevent it from moving, and also add

ontrigger nameoftrigger disable

so it doesn’t keep looping.

If you want it to be unpluggable:
On the prop_physics set the flag that says enable motion on physcannon and generate motion on USE, then add as an output to it

onplayerpickup nameoftrigger enable 

If you want to be extra fancy you can throw in keyframe_rope and a move_rope to give it a cable and even an env_spark.

This is a shitty and rough explanation but my SDK is broken so I can’t just mock one up for you. This is basically the gist behind the battery and plug puzzles in HL2. I can’t remember how the EP2 one is done.