I’m so frustrated so i hope you good people in the community can help I want to make my two GUI.Buttons from the code below to activate with keys and i’ve done it before in simpler scripts but it just won’t work here! Any help? Thanks!
var Pressed : boolean = false;
var charPressed : boolean = false;
var guiRatio : float;
var sWidth : float;
var GUIsF : Vector3;
var cube : GameObject;
var check : boolean = false;
function Awake(){
sWidth = Screen.width;
guiRatio = sWidth / 1440;
GUIsF = new Vector3(guiRatio,guiRatio,1);
}
function Update(){
if(cube == null){
check = true;
}
}
function OnGUI(){
if(check){
GUI.matrix = Matrix4x4.TRS(new Vector3(Screen.width - 100*GUIsF.x,Screen.height - 60*GUIsF.y,0),Quaternion.identity,GUIsF);
if(GUI.Button(new Rect(-20,-20,100,60),"Deer")){
gameObject.GetComponent(CharacterMotor).jumping.baseHeight = gameObject.GetComponent(CharacterMotor).jumping.baseHeight + 3;
Pressed = true;
if(gameObject.GetComponent(CharacterMotor).jumping.baseHeight >= 4){
gameObject.GetComponent(CharacterMotor).jumping.baseHeight = 4;
}
}
}
if(Pressed){
GUI.matrix = Matrix4x4.TRS(new Vector3(Screen.width - 100*GUIsF.x,Screen.height - 60*GUIsF.y,0),Quaternion.identity,GUIsF);
if(GUI.Button(new Rect(-20,-100,100,60),"Stop")){
gameObject.GetComponent(CharacterMotor).jumping.baseHeight = 1;
Pressed = !Pressed;
}
}
}