Hi,
I am trying to rotate the First Person Controller camera with the Q and E buttons as like you would peek around a corner.
I tried this script, but I don’t see the camera change at all. What am I doing wrong or how can I get this to work? ![]()
var leanLeft : boolean = false;
var leanRight : boolean = false;
function Update () {
if(Input.GetKeyDown("q")) {
doLeanLeft();
}
if(Input.GetKeyDown("e")) {
doLeanRight();
}
if(Input.GetKeyUp("q")) {
doLeanBack();
}
if(Input.GetKeyUp("e")) {
doLeanBack();
}
}
function doLeanLeft() {
if(leanLeft == false) {
transform.rotation = Quaternion.Euler(0,0,30);
leanLeft = false;
}
}
function doLeanRight() {
if(leanRight == false) {
transform.rotation = Quaternion.Euler(0,0,-30);
leanRight = false;
}
}
function doLeanBack() {
transform.rotation = Quaternion.Euler(0,0,0);
}