- Home /
Question regards a third party framework. See comments for a link to the question in Fungus' forums.
Fungus C# ExecuteBlock() won't execute when triggered by collision or trigger enter…!
Hey folks, long time C#/Unity user, first time Fungus user with a baffling conundrum for you. Having followed Youtube Fungus tutorial 16 (Extending Fungus), I sought to trigger a Fungus flow on the interaction of two rigidbodies (initially with OnCollisionEnter, then later OnTriggerEnter).
I'm ‘using Fungus’, I'm inheriting from EventHandler and I intended calling ExecuteBlock() from OnCollisionEnter… But while other commands in the OnCollisionEnter event (and inside the CompareTag if statement) ran (including some Debug.Logs), I couldn't get ExecuteBlock() to start the next block in the Flowchart chain to run!
And then I did a simple “if(input.GetKeyDown(KeyCode.Space) ExecuteBlock()” in Update and the bloody thing works!
So I figured that this had to be executed in Update, perhaps, so I tried making it run in an if statement which evaluated a bool set by the collision. No such luck.
I even tried making it work with the Invoke command that was demonstrated in the video – nope, nope, nope.
What on earth is going on here? I'm sure there's something obvious (multiple typos? God, I hope not) at root cause – perhaps somebody here can see the issue. Again, to restate: it's working on a simple buttonpress, NOT when it has something to do with an on enter collision/trigger.
Any thoughts? Screenshot and code follow… —Rev 
using UnityEngine;
using System.Collections;
using Fungus;
[EventHandlerInfo("Scripting", "LarryMazeEndzone", "Prevents Larry from moving, executes end cutscene")]
public class Endzone : EventHandler {
private StageManager stageManager;
//private Flowchart flowChart;
private bool completed = false;
// Use this for initialization
void Start () {
stageManager = GameObject.Find("Main Camera").GetComponent<StageManager>();
//flowChart = GameObject.Find("Flowchart").GetComponent<Flowchart>();
}
void Update()
{
if (completed)
{
ExecuteBlock(); // This does not run.
Debug.Log("Completed");
}
if (Input.GetKey(KeyCode.Space))
{
ExecuteBlock(); // This does run - even when I hold down spacebar!
Debug.Log("Space pressed");
}
}
void OnTriggerEnter (Collider other)
{
Invoke("ExecuteDammit",0.0f);
completed = true;
Debug.Log("Detected object");
if (other.transform.CompareTag("Larry"))
{
ExecuteBlock(); // This does not run...! (Obviously, this is the version I really want to be able to use)
Debug.Log("Touched Endzone!");
stageManager.CutsceneStarting();
Debug.Log("Executed Block, supposedly.");
}
}
void ExecuteDammit ()
{
Debug.Log("Method invoked...");
ExecuteBlock(); // No good, not executing.
}
}
Using the following code I was able to workaround the issue, but I'd still appreciate a response on ExecuteBlock() if possible...
public class Endzone : $$anonymous$$onoBehavior {
void OnTriggerEnter (Collider other)
{
Flowchart.BroadcastFungus$$anonymous$$essage(“ENTERED_ENDZONE”);
}
}
It is hard to get an answer to something that isn't built into unity and not everyone has. Have you tried asking the creator of fungus?
For questions about specific frameworks (like Fungus), it's often better to ask that framework's community in general, rather than the Unity-wide Answers.
Fungus has it's own forums, try there. You're more likely to find help.
I hadn't heard about Fungus before I read your question.
EDIT: I see you've already posted there. I'll close this question. The thread on the Fungus forums are here.