Cables on Models

From Valve Developer Community
Revision as of 11:16, 17 October 2009 by Rozzy85 (talk | contribs)
Jump to navigation Jump to search

Cables can be placed onto models simply by placing the correct code into the QC file. The cables work in the same fassion as the ones created using the move_rope and keyframe_rope entities only that they're more limited in that they can not be broken or made solid. A good example of usage of these cables is the model of Dog from HL2.

Note.pngNote:If used on props, the prop entity must be set as prop_dynamic for the cables to work.

Adding cables to a model

Cables are added to a model first by defining $attachment points.

$attachment "point1" "staticprop" 0.00 0.00 9.50 rotate 0.00 0.00 0.00
$attachment "point2" "staticprop" -128.00 0.00 9.50 rotate 0.00 0.00 0.00
$attachment "point3" "staticprop" 0.00 0.00 25.50 rotate 0.00 0.00 0.00

The code to create the cables must be placed within the $keyvalues block in another block titled Cables. Every time you want to create a single cable you must create a block titled "Cable"

StartAttachment <attachment name>

The $attachment point the cable starts from.

EndAttachment <attachment name>

The $attachment point the cable ends to.

Width <float>

Defines the width of the cable.

Material <VMT file location>

The VMT (material) to use. Cable materials are located in "materials/cables".

NumSegments <int>

The amount of segments in the cable. More segments make the cable more 'smooth'. Should be increased if the cable bends a lot.

Length <int>

The length of cable between the two attachment points. If the length is shorter than the distance between the two points then the cable will remain permanently straight.

Example

In this example, two cables are create between the three attachment points.

$keyvalues
{
    Cables
    {
        "Cable"
        {
            "StartAttachment" "point1"
            "EndAttachment" "point2"
            "Width" "0.6"
            "Material" "cable\cable"
            "NumSegments" "4"
            "Length" "200"
        }
        "Cable"
        {
            "StartAttachment" "point2"
            "EndAttachment" "point3"
            "Width" "0.6"
            "Material" "cable\cable"
            "NumSegments" "6"
            "Length" "250"
        }
    }
}