i am currently trying to add to a mini golf tutorial i got earlier by adding a power variable to the shot. The problem i have is that i can’t get a boolean to be set to true when releasing the h key. Is there any way to get around this?
function powerGuage() {
var hitDirection:Vector3=Vector3(ball.transform.position.x - transform.position.x, 0.0f, ball.transform.position.z - transform.position.z).normalized;
if(Input.GetKey("h") shot ==false){
shotPower += Time.deltaTime;
if(Input.GetKeyUp("h")){
print("key");
keyReleased = true;
print("keyReleased");
if(shotPower >=3 keyReleased){
shot=true;
GUIScript.shotNumber++;
print ("hit the ball");
ball.rigidbody.AddForce(hitDirection * hitForce, ForceMode.Impulse);
}
if(shotPower <=3 keyReleased){
shot=true;
GUIScript.shotNumber++;
print ("hit the ball");
//var hitDirection:Vector3=Vector3(ball.transform.position.x - transform.position.x, 0.0f, ball.transform.position.z - transform.position.z).normalized;
ball.rigidbody.AddForce(hitDirection * (hitForce*shotPower), ForceMode.Impulse);
}
}
}
}