Difference between revisions of "$controller"

From Valve Developer Community
Jump to: navigation, search
(Example)
(Significant re-write of the page. New example code with inline comments. Completely re-worked explanation of the syntax so it is compatible with modern studiomdl.)
 
Line 1: Line 1:
Creates a channel to manually set a single axis position or angle on a bone. Not recommended for use, mostly these exist since Half-Life 1 used them.
+
Creates a channel to manually set a single axis position or angle on a bone through game code. Not recommended for use, as this functionality was succeeded by [[$poseparameter]] and [[$sequence]].
 +
 
 
{{Warning|You can't assign more than 6 controllers to a single bone.}}
 
{{Warning|You can't assign more than 6 controllers to a single bone.}}
  
 
== Syntax ==
 
== Syntax ==
 +
$controller <number> "<bone_name>" [L]<axis>[R] <start> <end>
  
$controller <number> "<bone_name>" [L]<axis>[R] <start_angle> <end_angle>
 
 
where
 
where
 
; <number> : The number of the controller (you may need multiple controllers). 0-3 for custom controller, 4 or "mouth" for jaw (GoldSrc only).
 
; <number> : The number of the controller (you may need multiple controllers). 0-3 for custom controller, 4 or "mouth" for jaw (GoldSrc only).
; <bone_name> : the name of the bone to control.
+
; <bone_name> : The name of the bone to control.
; <axis> : The axis can be either X, Y, or Z. You need to specify a new controller for each axis of rotation.   
+
; <L> : The prefix 'L' specifies that the controller is to loop the bone movement from the <end> to the <start>. {{Warning|GoldSrc only.}}
; [L] : The prefix L on the axis specifies that this controller loops back around to the start when it ends (see example below).
+
; <axis> : The axis can be either X, Y, or Z. You need to specify a new controller for each axis of movement/rotation.   
; [R] : The suffix R specifies the angles are in {{wiki|radian}}s instead of degrees (see example below).
+
; [R] : The suffix 'R' specifies that the bone is to be rotated from <start> {{wiki|degrees}} to <end> {{wiki|degrees}}. Not including 'R' simply moves the bone along the <axis> from <start> world [[unit]]s to <end> world [[unit]]s.
; <start_angle> : the offset start angle of the rotation in degrees (or radians).
+
; <start> : Starting value of the controller.
; <end_angle> : the offset end angle of the rotation in degrees (or radians).  
+
; <end> : End value of the controller.
 +
 
  
=== Example ===
+
== Example ==
  $modelname "npcs/robot.mdl"
+
  $modelname "WScanner_Single.mdl"
  $cdmaterials "models/npcs/"
+
$model "WScanner" "WScanner_Single_Waste_Scanner_Reference.smd"
  $model "Robot" "robot.smd"
+
  $cdmaterials "models\obsolete\waste_scanner\"
  '''$controller mouth "jaw" X 0 20'''
+
//This controller rotates the root bone from 0 to 360 degrees.
  '''$controller 0 "tracker" LYR -1 1'''
+
  '''$controller 0 "Dummy (Root)" ZR 0 360'''
$sequence "idle" "idle.smd"
+
//Controller 1 has two entries to allow for the bone to travel 17 units in the X(-Z) direction.
 +
//$controller lines can only have one direction specified, so this allows for blending the movement.
 +
//move the antenna base bone from 0 to 17 units in the X direction.
 +
  '''$controller 1 "Antenna Base" X 0 17'''
 +
//move the antenna base bone from 0 to -17 units in the Z direction.
 +
  '''$controller 1 "Antenna Base" Z 0 -17'''
  
{{TODO|confirm syntax of "tracker"}}
 
  
 
[[Category:QC Commands|controller]]
 
[[Category:QC Commands|controller]]

Latest revision as of 18:03, 22 October 2017

Creates a channel to manually set a single axis position or angle on a bone through game code. Not recommended for use, as this functionality was succeeded by $poseparameter and $sequence.

Warning.png Warning: You can't assign more than 6 controllers to a single bone.

Syntax

$controller <number> "<bone_name>" [L]<axis>[R] <start> <end>

where

<number> 
The number of the controller (you may need multiple controllers). 0-3 for custom controller, 4 or "mouth" for jaw (GoldSrc only).
<bone_name> 
The name of the bone to control.
<L> 
The prefix 'L' specifies that the controller is to loop the bone movement from the <end> to the <start>.
Warning.png Warning: GoldSrc only.
<axis> 
The axis can be either X, Y, or Z. You need to specify a new controller for each axis of movement/rotation.
[R] 
The suffix 'R' specifies that the bone is to be rotated from <start> degrees to <end> degrees. Not including 'R' simply moves the bone along the <axis> from <start> world units to <end> world units.
<start> 
Starting value of the controller.
<end> 
End value of the controller.


Example

$modelname "WScanner_Single.mdl"
$model "WScanner" "WScanner_Single_Waste_Scanner_Reference.smd"
$cdmaterials "models\obsolete\waste_scanner\"
//This controller rotates the root bone from 0 to 360 degrees.
$controller 0 "Dummy (Root)" ZR 0 360
//Controller 1 has two entries to allow for the bone to travel 17 units in the X(-Z) direction.
//$controller lines can only have one direction specified, so this allows for blending the movement.
//move the antenna base bone from 0 to 17 units in the X direction.
$controller 1 "Antenna Base" X 0 17
//move the antenna base bone from 0 to -17 units in the Z direction.
$controller 1 "Antenna Base" Z 0 -17