- Home /
Actual name of target velocity?
Ok, so I'm trying to directly modify the target velocity of a hinge joint (HJ). I've tried a few things like "HJ.TargetVelocity = 500" and "HJ.targetVelocity = 500" and "HJ.Target Velocity = 500"... You know the routine.
So, what is this variable actually called? I know there are some texturing variables that have different names in the code than what shows up in the inspector. Here's a snippet if it helps understand my question.
var firing : boolean = false;
var HJ : HingeJoint;
function Start () {
HJ = gameObject.GetComponent (HingeJoint);
}
function Update () {
if (firing){
HJ.targetVelocity = 500;
}
else{
HJ.targetVelocity = 0;
}
}
Answer by psychentist · Feb 17, 2012 at 11:10 PM
AHA! I found it. Here's the correct code.
function Start () {
HJ = gameObject.GetComponent (HingeJoint);
}
function Update () {
if (firing){
HJ.motor.targetVelocity = 500;
}
else{
HJ.motor.targetVelocity = 0;
}
}
As you can see, I just needed to add the .motor. , and use the normal scheme of lowercase, then capitals. Duh. Oh well, I'll leave this up, maybe it will help someone else.
Answer by Harabeck · Feb 17, 2012 at 11:04 PM
The docs only mention a velocity variable.
http://unity3d.com/support/documentation/ScriptReference/HingeJoint-velocity.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613064210im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
hinge joint help? 0 Answers
Questions about physics based combat (animation + collision, hinge joints++) 0 Answers
Detecting collision with object what touched and making a hinge joint between. 1 Answer
I need help with the wheels of a shopping cart 0 Answers
Hingejoint doesn't work in Legacy mod? 0 Answers