x


translating this C# to javascript. (Camera Crouch)

using UnityEngine; using System.Collections;

public class CameraCrouchOffset : MonoBehaviour { public float StandingEyeHeight = 0.0f; public float CrouchingEyeHeight = -0.75f; // Use this for initialization void Start () {

}

// Update is called once per frame
void Update () {
//The transform.up, below, gives the object's own "up" vector, rather than world's "y" axis. This is better practice.
Vector3 StandingEyeOffset = transform.up * StandingEyeHeight;
Vector3 CrouchingEyeOffset = transform.up * CrouchingEyeHeight;

//The value of Input.GetAxis("Crouch") is going to be between 0 and 1. 
//So when it's at zero, the camera's offset will be equal to StandingEyeOffset. 
//When it's 1, the offset will be the same as CroucingEyeOffset. 
//If it's anywhere inbetween, it will be a blend of the two target vectors.
transform.position = Vector3.Lerp(StandingEyeOffset, CrouchingEyeOffset, Input.GetAxis("Crouch") );
}

}

more ▼

asked Aug 24 '10 at 02:07 AM

wishing gravatar image

wishing
17 2 4 4

"translating this C# to javascript" is not a question. I assume you want a JS version of it. Make an effort. If you get hung up, ask an actual question so we can help you get through it.

Aug 24 '10 at 02:36 AM Jessy

We could translate it, but you'll learn so much more doing it yourself, it's worth the effort.

Aug 24 '10 at 05:24 AM DaveA
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x223

asked: Aug 24 '10 at 02:07 AM

Seen: 695 times

Last Updated: Aug 24 '10 at 02:07 AM