bpears
1
I set values very high just to see if it would speed up the door, but it is the same it seems.
var moveSpeed:float = 99999999;
var offsetPosition:Vector3 = Vector3.zero;
private var startPos:Vector3 = Vector3.zero;
function Start()
{
startPos = transform.localPosition;
}
function Update (){
if(open == true){
transform.localPosition = Vector3.Lerp(transform.localPosition, transform.localPosition + offsetPosition, moveSpeed*99999999999999999 * Time.deltaTime);
}
if(open == false){
transform.localPosition = Vector3.Lerp(transform.localPosition, startPos, moveSpeed * Time.deltaTime);
}
if(enter == true){
if(Input.GetButtonDown("Reload")){
open = !open;
}
}
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
(enter) = true;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
(enter) = false;
}
}
The last parameter of a Vector3.Lerp is the percentage of which it will move from the first point to the second. It must be between 0 and 1 (and is clamped between 0 and 1).
Some examples:
0 - don’t move at all.
0.5 - move halfway this frame.
1 - move all the way this frame.
Output Time.deltaTime and you will see that it is very small
Try using Time.time
Also, next time check out the docs before posting. Unity - Scripting API: Vector3.Lerp
There are many examples to help you along.