Hallo my script changes a variable back to true but it says it goes to false.
i need help it is a fishing script but i can't found the problem.
here is simple explanation what i must do :
- see if the player is in the cube(with isTrigger on)
- if he pres e go and fish
- if he is fishing generate random waits (for every tug)
- after al those tugs reset the variables
after 3 it goes the wrong way please help me
here is the code
var target : Transform;
var FishingPool : Transform;
var rotationY :float= 0.0;
private var showGUI = false;
private var isFishing = false;
private var tugFish = false;
private var changeble = true;
function Update () {
print("show gui:"+showGUI +" isFishing:"+ isFishing +" tugFish:"
+ tugFish +" changeble :"+ changeble);
if(showGUI) {
if(Input.GetKeyDown("e")) {
if(!isFishing) {
target.GetComponent(ThirdPersonController).enabled = false;
target.localEulerAngles.y = rotationY;
target.animation.Stop();
target.animation.Play("fishing");
isFishing = true;
} else {
target.GetComponent(ThirdPersonController).enabled = true;
isFishing = false;
}
}
if(!isFishing)
target.GetComponent(ThirdPersonController).enabled = true;
else fish();
}
if(changeble) tugFish = false;
}
function OnTriggerEnter() {
showGUI = true;
}
function OnTriggerExit() {
showGUI = false;
}
function OnGUI() {
if(showGUI) {
if(!isFishing)
GUI.Label(Rect(Screen.width/2-50, 50,100,30),"Press E to Fish");
else
GUI.Label(Rect(Screen.width/2-75, 50,150,30),
"Press E to cancel fishing");
if(isFishing) {
if(tugFish && GUI.Button(Rect(Screen.width/2 +50,50,60,30),
"PULL!")) {
}
else if(GUI.Button(Rect(Screen.width/2 +50,50,60,30),"PULL!")) {
tugFish = false;
isFishing = false;
changeble = true;
}
}
}
}
function restart() {
yield WaitForSeconds(2);
target.GetComponent(ThirdPersonController).enabled = true;
}
function fish() {
if(isFishing) {
changeble = false;
var tug1 = Random.Range(7, 12);
var tug2 = Random.Range(6, 10);
var tug3 = Random.Range(1, 2);
yield WaitForSeconds(tug1);
target.animation.Play("tug");
yield WaitForSeconds(tug2);
target.animation.Play("tug");
tugFish = true;
yield WaitForSeconds(tug3);
changeble = true;
yield;
isFishing = false;
tugFish = false;
}
}