Code (csharp): def JumpScare() as IEnumerator: Debug.Log("Started Co") while timeChange < 10: Debug.Log("Break") if bIamRunning == true: Debug.Log("Running TimeChange") timeChange = 0 Debug.Log("Set time to 0") yield WaitForSeconds(0.1) Debug.Log("Waited for .1 secs") elif bIamRunning == false: Debug.Log("Waiting for a sec...") yield WaitForSeconds(1) Debug.Log("waited.") timeChange += 1 Debug.Log("Added one to timeChange") if timeChange >= 10: audioPlayed = false timeChange = 0 Debug.Log("Can play audio again!") else: pass And where the coroutine gets called: Code (csharp): if flashObj.light.enabled == false: if bIamRunningF == false: StartCoroutine("FlashlightOffSanity") else: pass elif Monsterd.renderer.isVisible == true or dist < 5: if dist > 100: bMonsterVisibleRange = false else: bMonsterVisibleRange = true if bIamRunning == true: pass else: StopAllCoroutines() StartCoroutine("ISeeTheMonsterMan") if (audioPlayed == false) and (dist < 20): scarySound.audio.Play() audioPlayed = true StartCoroutine("JumpScare") else: pass Basically, it works the first time I look at him, and counts up as planned. However, if I look at the monster one more time, the flashlight DOES reset to 0, but when I look away it doesn't restart counting up. Why? :\
Don't make us read your code just to understand what you're asking. minus the code you basically just say: Really? who is him? How are you looking at him? What "counts up"? What is the monster? What is the flashlight, and what does reseting to 0 mean? And when you look away from what, what starts counting up? Why? WHY? How in the hell do we know!?
I don't have a name at the monster Occlusion culling. When the screen renders him, you are looking at him. As soon as he is behind an object or not being looked at, he is no longer rendered, effectively, he is not being looked at. ... A timer. It doesn't really matter. A spotlight. If you read the code, the timer = 0. Look away from the monster, the timer goes up. You read the code. This IS the scripting forum.
I was looking at that code thinking, wtf is this S***!? Then im like, oh its boo... well what an ugly pos language that is. Thats where my interest in this thread ended.
Whoa, Boo. Typo? I don't see timeChange set anywhere before JumpScare is called (don't know if Boo autodeclares or anything). I think you'd have to set it before starting the coroutine. Also - timeChange is too nondescript of a variable name for me to understand what it's doing. :S I had to write in stupid Python to fix Blender's broken FBX exporter. ... I can look at Boo and almost understand it
Show's your open mind. This is where my interest of any games you make in the future end. My favorite language in Unity. Only language I'll use. bIamRunningF actually isn't It's to let me know between different bools. One is bIamRunning, bIamRunningS, and bIamRunningF. While they may have little meaning to you, I know exactly what each is for It's declared globally in the beginning of the script, it just isn't shown Originally, I used it to check between two Time.time checks. Now, it's just not changed. Basically, it is a timer variable. Outside of Unity, I will only write in Python because I believe it is the best language out there. The conventions of Python, and in effect Boo, are beautiful.
I mean, each time - Code (csharp): if (audioPlayed == false) and (dist < 20): scarySound.audio.Play() audioPlayed = true // Don't you need to set timeChange to zero here? Otherwise it's undefined if JumpScare has ever run. The timer is resetting to zero because, in JumpScare, it's set to zero if it's greater than 10. StartCoroutine("JumpScare") else: pass I will say this for Python/Boo-style syntax - it's much, much more gentle on the eyes than the Lisp-derivative I had to use in school. I do favor languages with absolutely no claim on whitespace, though.
I know enough languages without getting into another somewhat inadequate looking one that ill never even consider using. Good for you choosing the underdog. Its not like youve shown any yet anyway, so no loss there