- Home /
Question by
Fulvio13 · Apr 30, 2012 at 04:03 PM ·
first-person-controller
Moving the first person controller upwards and downwards
Hello, I'm currently making a game where the player must avoid incoming projectiles, and during this development I've encounter a slight problem were I'm not sure on how to make the first person controller move either upwards and downwards (by default it moves forward and backwards).
Therefore I began searching through the first person controller script and encountered a particularly interesting function:
function Update () {
// Get the input vector from kayboard or analog stick
var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
I understand that this maps X and Z directions of the vector and puts 0 in Y. I was wondering if there was anyway way I could I swap the Y and Z to make it go up and down instead?
Thanks!
Comment
Answer by bompi88 · Apr 30, 2012 at 06:45 PM
Like this? You have to turn off gravity though.
var directionVector = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);