Skip to content

Instantly share code, notes, and snippets.

@Atlas48
Created June 9, 2019 21:01
Show Gist options
  • Save Atlas48/a18d9976fede071909e88f3c9818f7a0 to your computer and use it in GitHub Desktop.
Save Atlas48/a18d9976fede071909e88f3c9818f7a0 to your computer and use it in GitHub Desktop.
Handy fungus trigger.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Fungus;
public class FungusTrigger : MonoBehaviour {
//public Flowchart fc;
public bool ready = false;
public string ToCall;
private bool inProxim;
void OnCollisionEnter(UnityEngine.Collision c) {
var go = c.gameObject;
var player = c.gameObject.transform.parent;
inProxim = (go.tag == "playerCollision");
}
private void OnCollisionExit(UnityEngine.Collision collision) {
inProxim = false;
}
private void Update() {
if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.Return) && inProxim) {
Flowchart.BroadcastFungusMessage(ToCall == "" ? "error" : ToCall);
}
}
}
fileFormatVersion: 2
guid: fae228b89a2e6e540b6f21127b66d522
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &431583200104080096
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 429605045878404648}
- component: {fileID: 370079024548527122}
- component: {fileID: 319573316769628836}
m_Layer: 0
m_Name: FungusTrigger
m_TagString: Untagged
m_Icon: {fileID: 7174288486110832750, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &429605045878404648
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 431583200104080096}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4, y: 2, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &370079024548527122
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 431583200104080096}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!114 &319573316769628836
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 431583200104080096}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fae228b89a2e6e540b6f21127b66d522, type: 3}
m_Name:
m_EditorClassIdentifier:
ready: 0
ToCall: s1
fileFormatVersion: 2
guid: ec9952d05e96a374bac3861104bf2327
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment