Submitted by
yesukai on Tue, 2005-03-29 22:02.
Hang 'Em High: phys_ballsocket
The Source engine features the Havok physics engine, which allows for a number of incredible physical simulations. To facilitate this, there are a number of entities that allow mappers to define the physical relationship between two entities. One of these entities is the phys_ballsocket. Think of it as, well, a ball and socket joint. One entity acts as the anchor, and the other entity is free to move around that anchor at a set distance. In our tutorial we are going to use this entity to hang a corpse.
Found In
phys_ballsocket is found in the Base FGD.
Tutorial
First make something in Hammer to hand the corpse from, be it a gallows, a tree, or whatever. I'm just going to use a simple gallows. Under the gallows, make a prop_ragdoll using the Entity Tool (shift-E). Give the ragdoll a name of "deadMan" and a world model of "models/Humans/corpse1.mdl". Now create a move_rope underneath him, and set its next keyframe to "hangRope1" and set its parent to "deadMan". This is the part that makes the rope stay with the corpse. Create a keyframe_rope above the ragdoll, right up at the gallows. Name this "hangRope1". Now, you have a rope that stretches from the gallows to the ragdoll, and will continue to do so even if the ragdoll is moved.
But wait, you say, what about the ballsocket? Well, as it is now, if you were to compile, the ragdoll will fall right to the ground. He will still be attached to the rope, but the rope will simply stretch to allow him to fall. This is where the phys_ballsocket comes in. Create one right where you made you keyframe_rope. Open up its properties and simply set Entity 1 to "deadMan". The engine will use the phys_ballsocket as the other entity if you dont specify one. Now the corpse is incapable of moving farther away from the phys_ballsocket then it currently is; however, it may move in a spherical pattern around the phys_ballsocket.
Lets have a look at some of the important values from the phys_ballsocket:
- Name: Use this to set the name of the phys_ballsocket, useful if you had to trigger the ballsocket; an example of which would have the rope trigger the ballsocket off when it breaks.
- Entity 1: The first entity to join together.
- Entity 2: The second entity to join together.
- Constraint System Manager: If you have multiple phys_ constraints acting on our dead man, you would want to make them part of the same system or else they would fight each other. An example would be if you wanted to have our hanging man tethered to a wall and hanging from the gallows.
- Force Limit to Break: If the player (or something else) gets particularly frisky with the corpse, you can have the ballsocket stop working (break).
- Force Limit to Break: Same as above.
- Play Sound on Break: Play a sound when the ballsocket breaks, like a nice snapping sound.
Technical Data
phys_ballsocket
KEYS
Name targetname target_source
spawnflags spawnflags flags
Entity 1 attach1 target_destination
Entity 2 attach2 target_destination
Constraint System Manager constraintsystem target_destination
Force Limit to Break (lbs) forcelimit float
Torque Limit to Break (lbs * distance) torquelimit float
Play Sound on Break breaksound sound
INPUTS
Kill: Removes this entity from the world.
KillHierarchy: Removes this entity and all its children from the world.
AddOutput: string Adds an entity I/O connection to this entity. Format: output name targetname:inputname:parameter:delay:max times to fire (-1 == infinite). Very dangerous, use with care.
FireUser1: Causes this entity's OnUser1 output to be fired.
FireUser2: Causes this entity's OnUser2 output to be fired.
FireUser3: Causes this entity's OnUser3 output to be fired.
FireUser4: Causes this entity's OnUser4 output to be fired.
Break: Force the constraint to break.
TurnOn: Enable the constraint. Do this when the objects don't exist when the constraint spawns - or when you have deactivated the constraint. Broken constraints can NOT be turned on. They have been deleted.
TurnOff: Disable this constraint.
OUTPUTS
OnUser1: Fired in response to FireUser1 input.
OnUser2: Fired in response to FireUser2 input.
OnUser3: Fired in response to FireUser3 input.
OnUser4: Fired in response to FireUser4 input.
OnBreak: Fired when the constraint breaks.
Doors in HL2: The prop_door_rotating Entity
Reducing Vis Times