- Home /
This question was
closed Jun 23, 2014 at 12:53 AM by
ikelaiah for the following reason:
The question is answered, right answer was accepted
Question by
ikelaiah · Feb 27, 2014 at 03:24 AM ·
velocityjointconfigurablejointscrpting
How to gradually increase targetAngularVelocity value of a Configurable joint?
How do I gradually increase the speed of a configurable joint? When I assigned a value of Vector3(0,0,5) to a conjo rotating about z-axis, value 5 is applied instantly. Is there a way to make the speed goes up gradually to assigned speed?
Comment
Best Answer
Answer by nesis · Feb 27, 2014 at 04:16 AM
You can use Vector3.Lerp(). As an example:
private const float Duration = 2f;
private float endTime = -1f;
private Vector3 startValue;
private Vector3 endValue;
public void Update() {
if (Time.time<=endTime) {
float a = (endTime-Time.time)/Duration;
Debug.Log(Vector3.Lerp(startValue,endValue,a));
}
else if (Input.GetKeyDown(KeyCode.E)) {
endTime = Time.time + Duration;
startValue = transform.position;
endValue = startValue + Vector3.right;
}
}
Follow this Question
Related Questions
Joint system scale problems 2 Answers
OnJointBreak 1 Answer
Does it matter if a joint chain is in hierarchy? 0 Answers
Configurable Joint: Unable to keep distance the same 2 Answers
How to stop objects from losing energy due to joints? 0 Answers