Calling a Function from a script reference in Inspector
I am working on a system in which a script attached to a GameObject should trigger a function from a script referenced in the Inspector. Is there any way to call a function from a separate script on the same gameobject without "finding" it first, but referencing it directly?
The idea is to be able to drag and drop several different parts of spells (scripts) and linking them together to form custom spells.
public class Spell : MonoBehaviour {
public string spellname = "Spell";
public string description = "a spell";
public MonoBehaviour Trigger;
public List<Vector3> pattern = new List<Vector3>();
public void SpellTrigger ()
{
print(spellname + ": Activating Component" + Trigger);
Trigger.SpellTrigger()
}
This fails to build, as Trigger does not contain the function SpellTrigger() If i comment out the last line, the console outputs the name of the referenced script, but that's as far as I've gotten.
Your answer

Follow this Question
Related Questions
How do I add two different values from a script on seperate game objects? 0 Answers
Why is the this object referenced to itself? 1 Answer
Need to add a reference to script once added with code? 0 Answers
create action on touch release 1 Answer
CS0029 Error cannot implicity convert type 'bool' 'UnityEngine.Rendering.ShadowCastingMode' 1 Answer