Question by
TheZipCreator · Oct 02, 2016 at 12:01 AM ·
unity 5movementvertical
How Do You Make Vertical Movement?
I have a script and I want to make it able to have vertical movement, But i don't know how. Here's my script.
var speed : float = 5;
var mH : Vector3 = Vector3.zero;
var mV : Vector3 = Vector3.zero;
var grav : float = 15;
//Set Variables ^
//Major Functions V
function Update() {
var control : CharacterController = GetComponent(CharacterController);
if (control.isGrounded) {
mH = Vector3(Input.GetAxis("Horizontal"), 0, 0);
mH = transform.TransformDirection(mH);
mH *= speed;
mV = Vector3(0, 0, Input.GetAxis("Vertical"));
mV = transform.TransformDirection(mV);
mV *= speed;
}
//Movement
control.Move(mH * Time.deltaTime);
control.Move(mV * Time.deltaTime);
mH.y -= grav * Time.deltaTime;
mV.y -= grav * Time.deltaTime;
}
Comment