fungus

Open full view…

Script error when trying to execute a flowchart block

kevynthomas
Wed, 13 Jun 2018 04:44:44 GMT

So I've used the same script from the documentation page of Fungus, but it seems like it won't work because of this one error. Please help lol. [Ua](//muut.com/u/fungus/s2/:fungus:z150:ua.png.jpg)

Steve Halliwell
Wed, 13 Jun 2018 10:43:44 GMT

Not sure exactly what you are trying to do, but it looks like you might be trying to call what would be a method directly on the class rather than on an instance of a flowchart. If you can share more of the surrounding code you have someone may be able to assist further.

kevynthomas
Fri, 15 Jun 2018 03:17:59 GMT

Alright, so I want to execute a fungus block from a flowhcart if the raycast (When you click the object) activates the fungus block. Everything I've tried so far with the coding has failed and I'm not sure what to use in order for it to register the action. [As](//muut.com/u/fungus/s3/:fungus:2PV3:as.png.jpg)

Steve Halliwell
Sat, 16 Jun 2018 00:03:39 GMT

Ok so assuming the debug log in that sample fires correctly, you just need a way to reference a flowchart and a block. If this is a script that goes on every element that can be clicked then you want either a public Flowchart variable and a public string variable that you assign in the inspector so when it is clicked you then ExecuteBlock on you flowchart variable passing in the block name variable. Or if using the latest from github you can make use of https://github.com/snozbot/fungus/blob/master/Assets/Fungus/Scripts/Utils/BlockReference.cs If this is a script that sits on the player and there are lots of flowcharts in the world that should all be clickable. Then you'll either need to start making some assumptions, like if everything that has a fungus flowchart that is also fpsclickable it must have a block named FPSClick. Then you could do a GetComponent on the hit object where the debuglog is, get its flowchart and if not null tell it to execute some predet ermined block name. -The fancier version of this would be to create a new Fungus Event type that your FSPClick attempts to GetComponent and fire.

kevynthomas
Sat, 16 Jun 2018 00:17:49 GMT

Your link does not exist. Can you send another one? or maybe some code that could work?

kevynthomas
Sat, 16 Jun 2018 01:15:35 GMT

Wait, scratch that, I was able to see what you posted. I'm still having some troubles understanding how to use the code provided (Not programmer savvy lol.) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using Fungus; public class FPSClick : MonoBehaviour { public bool FPSController = false; // Use this for initialization void Start() { } // Update is called once per frame void Update() { Flowchart flowchart = GameObject.FindObjectOfType<Flowchart>(); bool FPSController = flowchart.GetBooleanVariable("FPSController"); if (FPSController == (true)) if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 3)) { Debug.Log(hit.transform.name); //Select Stage if (hit.transform.name == "Shuichi Saihara sprite") { } } } } [System.Serializable] public struct BlockReference { public Block Saiharaclick; public void Execute() { if (Saiharaclick != null) Saiharaclick.StartExecution(); } } }

kevynthomas
Sat, 16 Jun 2018 06:20:13 GMT

While I appreciate the help you could've just sent me a send message code and that would've solved all my problems lol. Fungus.Flowchart.BroadcastFungusMessage("Saiharaclick");