This article's documentation is for anything that uses the Source engine. Click here for more information.

Phys spring: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(in progress)
No edit summary
 
(19 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{wrongtitle|title=phys_spring}}
{{TabsBar|main=s2|base=phys_spring}}
{{CD|CPhysicsSpring|file1=1}}
{{this is a|point entity|name=phys_spring|engine=Source}}  


==Entity Description==
It is a physically simulated spring. '''length''' is what's known as the "natural spring length". This is how long the spring would be if it was at rest (nothing hanging on it or attached). When you attach something to the spring, it will stretch longer than its natural length. The amount of stretch is determined by the spring constant '''constant'''. The larger the spring constant the less stretch in the spring.
A physically simulated spring. '''length''' is what's known as the "natural spring length". This is how long the spring would be if it was at rest (nothing hanging on it or attached). When you attach something to the spring, it will stretch longer than its natural length. The amount of stretch is determined by the spring constant '''constant'''. The larger the spring constant the less stretch in the spring.
{{tip|To break the spring and disconnect elements it holds together, fire {{code|Kill}} input on the spring.}}


==Keyvalues==
{{Official vmf example|sdk_phys_spring.vmf}}
*{{kv targetname}}
Entity 1 attach1 <target_destination>


Entity 2 attach2 <target_destination>
== Keyvalues ==
{{KV Targetname}}
{{KV|Entity 1|intn=attach1|target_destination|First entity to attach.}}
{{KV|Entity 2|intn=attach2|target_destination|Second entity to attach.}}
{{KV|Spring Axis|intn=springaxis|vecline|Use the helper. Drag it out to match the virtual spring.}}
{{KV|Spring Length|intn=length|string|How long the spring would be if it was at rest (nothing hanging on it or attached). 0 means the length of the brush.}}
{{KV|Spring Constant|intn=constant|string|Stiffness of the spring.  The larger the number the less the spring will stretch.}}
{{KV|Damping Constant|intn=damping|string|How much energy the spring loses.  The larger the number, the less bouncy the spring.}}
{{KV|Relative Damping Constant|intn=relativedamping|string|The amount of energy the spring loses proportional to the relative velocity of the two objects the spring is attached to.}}
{{KV|Break on Length|intn=breaklength|string|If the spring's length ever exceeds this length, the spring breaks.}}


Spring Axis springaxis <vecline> Use the helper. Drag it out to match the virtual spring.
== Flags ==
{{fl|1|Force only on stretch}}


Spring Length length <string> How long the spring would be if it was at rest (nothing hanging on it or attached). 0 means the length of the brush.
== Inputs ==
{{I|SetSpringConstant|Set the Spring Constant.|param=float}}
{{I|SetSpringLength|Set the Spring Length.|param=float}}
{{I|SetSpringDamping|Set the Spring Damping.|param=float}}


Spring Constant constant <string> Stiffness of the spring.  The larger the number the less the spring will stretch.


Damping Constant damping <string> How much energy the spring loses.  The larger the number, the less bouncy the spring.
[[Category:Constraints|C]]
 
Relative Damping Constant relativedamping <string> The amount of energy the spring loses proportional to the relative velocity of the two objects the spring is attached to.
 
Break on Length breaklength <string> If the spring's length ever exceeds this length, the spring breaks.
 
==Flags==
 
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.
 
SetSpringConstant <float> Set the Spring Constant.
 
SetSpringLength <float> Set the Spring Length.
 
SetSpringDamping <float> Set the Spring Damping.
 
 
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.

Latest revision as of 07:12, 29 April 2025

C++ Class hierarchy
CPhysicsSpring
CBaseEntity
C++ physobj.cpp

phys_spring is a point entity available in all Source Source games.

It is a physically simulated spring. length is what's known as the "natural spring length". This is how long the spring would be if it was at rest (nothing hanging on it or attached). When you attach something to the spring, it will stretch longer than its natural length. The amount of stretch is determined by the spring constant constant. The larger the spring constant the less stretch in the spring.

Tip.pngTip:To break the spring and disconnect elements it holds together, fire Kill input on the spring.
PlacementTip.pngExample:See steamapps/common/sourcesdk_content/hl2/mapsrc/sdk_phys_spring.vmf for example use (comes with Source SDK installation [confirm])

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Entity 1 (attach1) <targetname>
First entity to attach.
Entity 2 (attach2) <targetname>
Second entity to attach.
Spring Axis (springaxis) <vector>
Use the helper. Drag it out to match the virtual spring.
Spring Length (length) <string>
How long the spring would be if it was at rest (nothing hanging on it or attached). 0 means the length of the brush.
Spring Constant (constant) <string>
Stiffness of the spring. The larger the number the less the spring will stretch.
Damping Constant (damping) <string>
How much energy the spring loses. The larger the number, the less bouncy the spring.
Relative Damping Constant (relativedamping) <string>
The amount of energy the spring loses proportional to the relative velocity of the two objects the spring is attached to.
Break on Length (breaklength) <string>
If the spring's length ever exceeds this length, the spring breaks.

Flags

Force only on stretch : [1]

Inputs

SetSpringConstant <floatRedirectInput/float>
Set the Spring Constant.
SetSpringLength <floatRedirectInput/float>
Set the Spring Length.
SetSpringDamping <floatRedirectInput/float>
Set the Spring Damping.