- Home /
Question by
EliteHedgehog56 · Dec 23, 2017 at 12:22 PM ·
rotationtransformcontrols
aiming up and down
I am attempting at replicating the controls of the original metroid prime on the gamecube, I have pretty much got all of the controls set up, but I am missing the aiming up and down while free aiming, I have the left and right rotation set up but I can't get the aim up and down action to work, also when the free aim key is held down, the normal movement boolean is meant to disable and the free aim to enable but it seem to not want to work.
here's the script var canaim : boolean = false; var canlock : boolean = false; var normalmove : boolean = true; var turn = 30; var walk = 30; var enemy : Transform;
function FixedUpdate (){
if (Input.GetButton("Aim")){
canaim = true;
normalmove = false;
}
if (Input.GetButtonUp("Aim")){
canaim = false;
normalmove =false;
}
if (Input.GetButton("Lock")){
canlock = true;
normalmove = false;
}
if (Input.GetButtonUp("Lock")){
canlock = false;
normalmove = true;
}
if (normalmove){
if (Input.GetKey(KeyCode.D)){
transform.Rotate(Vector3.up * turn * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A)){
transform.Rotate(-Vector3.up * turn * Time.deltaTime);
}
}
if (Input.GetKey(KeyCode.W)){
transform.Translate(Vector3.forward * walk * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S)){
transform.Translate(Vector3.back * walk * Time.deltaTime);
}
if(canlock){
transform.LookAt(enemy);
if (Input.GetKey(KeyCode.W)){
transform.Translate(Vector3.forward * walk * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S)){
transform.Translate(Vector3.back * walk * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A)){
transform.Translate(Vector3.left * walk * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D)){
transform.Translate(Vector3.right * walk * Time.deltaTime);
}
}
if (canaim){
if (Input.GetKey(KeyCode.D)){
transform.Rotate(Vector3.up * turn * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A)){
transform.Rotate(-Vector3.up * turn * Time.deltaTime);
}
if (Input.GetKey(KeyCode.W)){
//aim up
}
if (Input.GetKey(KeyCode.S)){
//aim down
}
}
}
Comment