- Home /
Question by
thevraptor · Apr 17, 2014 at 02:27 AM ·
lerptransform.translate
Vector3.Lerp with Translate Javascript
Hello.
I am making a walljump script in which if the raycast is true and the spacebar is pressed, the player is moved backards in the manner of a walljump. I am trying to make it as smooth as possible, hence why there is Time.deltaTimes everywhere. I want to use a lerp, but don't know how to do that with a translate. Thanks.
var walljumpHeight : int = 30;
var walljumpLength : int = -50;
var raycastLength : int = 1;
function Start () {
}
function Update () {
var fwd = transform.TransformDirection (Vector3.forward);
if (Physics.Raycast (transform.position, fwd, raycastLength) && Input.GetButton ("Jump") ) {
transform.Translate(0, walljumpHeight * Time.deltaTime, walljumpLength * Time.deltaTime);
}
}
Comment
Please format your code, by either using the 101010
button or indenting it by four spaces.