I’m trying to call upon a function in an if statment, like
if(NameOfFunction() == true{
Execute code here;
}
But not entirely sure how to do it… Any help?
EDIT: Here’s the code incase it helps, It’s probably messy and there’s most likley much better ways of doing what i’m trying to do,But i’m learning and this is all of my own back which i’m somewhat proud of… Even though it doesn’t look like much
#pragma strict
static var haveFlashlight : boolean = false;
var Flashlight : GameObject;
var FindAudio : AudioClip;
var flashlightEmitter : Light;
var Footstep_Concrete : AudioClip;
var isMoving : boolean = false;
function Start () {
Screen.showCursor = false;
}
function Update(){
if(haveFlashlight == true Input.GetKeyDown("f")){
flashlightEmitter.enabled = !flashlightEmitter.enabled;
}
if(haveFlashlight == true){
Debug.Log("haveFlashLight = True");
audio.clip = FindAudio;
audio.Play();
audio.clip = Footstep_Concrete;
}
if(IsMoving() == true){
audio.clip = Footstep_Concrete;
if(!audio.isPlaying)
audio.Play();
Debug.Log("Moving");
}
}
function IsMoving(){
if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D)){
isMoving = true;
}
else if(!Input.GetKey(KeyCode.W) || !Input.GetKey(KeyCode.A) || !Input.GetKey(KeyCode.S) || !Input.GetKey(KeyCode.D)){
isMoving = false;
}
}