fungus

Open full view…

random chapters?

lamydelachapelle paul
Sat, 20 Oct 2018 14:40:24 GMT

Hey I'd want to write a story with 3 different chapters. Any chapter can appear first randomly. One flowchart per chapter. How can I do that? I am not a coder, thanks :)

koyemsi
Sun, 21 Oct 2018 02:02:30 GMT

Hi Paul. Here is a quite simple way to do so (there are probably plenty of others). Put this code in your main script. If you don't have one, create an empty GameObject, and attach this script to it : --- using System.Collections; using System.Collections.Generic; using UnityEngine; using Fungus; public class ChapterManager : MonoBehaviour { // create an array of flowcharts (don't forget to fill them in the inspector) public Flowchart[] myFlowcharts = new Flowchart[3]; // Use this for initialization void Start() { Flowchart startFlowchart = myFlowcharts[Random.Range(0, myFlowcharts.Length)]; startFlowchart.enabled = true; } } --- In order to work, this solution needs you to : - fill in the inspector fields with your flowcharts ; - disable the 3 flowchart scripts (not the game objets but their *flowchart script component*) - each flowchart must have a starting block, which will execute on event Scene>Flowchart Enabled. You should be good to go...

lamydelachapelle paul
Mon, 22 Oct 2018 20:11:14 GMT

hi Koyemsi, it is super nice to have your help on it. I will try it as soon as possible. I really hope that it will work!!! BIG thanks to you my friend. http://www.paul-lamydelachapelle.com

lamydelachapelle paul
Sat, 27 Oct 2018 20:21:35 GMT

hi @koyemsi , thanks a lot, it perfectly works! however I am looking for something a bit more complicated. first, I 'd want to have a flowchart introduction to introduce the story. then one of the three chapters appears randomly. after that, one of the two other chapters appears randomly. and then the last chapters appears. finally, there is a conclusion flowchart to finish the story. please can you help me on it because it is the last thing that I need to make my own visual novel :) http://paul-lamydelachapelle.com

vooils
Wed, 07 Nov 2018 13:26:40 GMT

Can u say something about a https://mobilerecorder24.com/#alex81 mobile recorder on Android? How does it work with other applications?

koyemsi
Tue, 30 Jul 2019 11:08:52 GMT

Hi Paul, sorry for my very late reply, didn't visit this forum for months. Glad I could help a bit. Did you work it out, or do you still need some help with your specific problem ?

lamydelachapelle paul
Tue, 30 Jul 2019 14:30:28 GMT

Hi @Koyemsi no worries thanks. Indeed I still need some help. Do you have a complete answer to this question? Cheers paul-lamydelachapelle.com

koyemsi
Tue, 30 Jul 2019 15:35:06 GMT

I don't at this time, but I will think about it and try to give you a quick answer. Cheers

lamydelachapelle paul
Tue, 30 Jul 2019 15:41:51 GMT

Thanks a lot

koyemsi
Tue, 30 Jul 2019 15:43:07 GMT

By the way, just gave a quick look to your website, and your work looks amazing ! Du très beau boulot (je pense que nous sommes francophones tous les 2, mais étant sur un site anglophone je vais continuer avec mon anglais approximatif ;)

koyemsi
Tue, 30 Jul 2019 17:44:06 GMT

OK, just figured it out. Let' go : Create 5 flowcharts : - 1 named Intro FC - 3 named Random FC 1, Random FC 2 and Random FC 3 - 1 named Conclusion FC Important : none of the blocks in your flowcharts should execute on the « Game Started » event. Set all of them on « None ». The script will handle their execution order. Create an empty GO named StoryManager, with a C# script named the same way. In its inspector, fill in the flowcharts fields. Each of your flowcharts (except for Conclusion FC) should end with this specific command : Scripting > Invoke method Description : jumps to next FC Target Object : StoryManager Target Component : StoryManager Target Method : ExecNextFlowchart() And you’re done ! Note that this script will work with as many randomized flowcharts as you want. With only 3 of them, the shuffling will sometimes result in the initial order (1,2,3) because there are only 3^2=9 possible combinations ;) Oh, nearly forgot the script ;) --- using System.Collections.Generic; using UnityEngine; using Fungus; public class StoryManager : MonoBehaviour { public Flowchart introFC; public Flowchart[] randomFC; public Flowchart conclusionFC; [HideInInspector] public List<Flowchart> flowchartsToExecute = new List<Flowchart>(); int flowchartIndex; void Start() { // Adding the first FC to the list flowchartsToExecute.Add(introFC); // Adding the random FCs to the list for (int i = 0; i < randomFC.Length; i++) flowchartsToExecute.Add(randomFC[i]); // Shuffling their order ShuffleList(flowchartsToExecute); // Finally adding the conclusion FC flowchartsToExecute.Add(conclusionFC); // init the index flowchartIndex = 0; // executes the 1st FC in the list ExecNextFlowchart(); } // Method for shuffling a list void ShuffleList(List<Flowchart> theList) { // Knuth shuffle algorithm :: courtesy of Wikipedia :) // important : begin at position 1 to prevent introFC from being shuffled for (int i = 1; i < theList.Count; i++) { Flowchart tmpFC = theList[i]; int r = Random.Range(i, theList.Count); theList[i] = theList[r]; theList[r] = tmpFC; } } // Method for jumping to the next FC public void ExecNextFlowchart() { Flowchart fc = flowchartsToExecute[flowchartIndex]; // will execute the 1st block in the FC fc.ExecuteBlock(fc.GetComponents<Block>()[0]); flowchartIndex++; } } ---

lamydelachapelle paul
Mon, 12 Aug 2019 07:57:04 GMT

@koyemsi hey! thanks a lot! I will try it as soon as possible :) paul-lamydelachapelle.com

koyemsi
Mon, 12 Aug 2019 10:43:00 GMT

You're welcome Paul. Just let me know if that does the job you were aiming for. Good luck.