Creating a New Trigger?

Creating a New Trigger?

PostPosted by GameDevKev » Sat Dec 05, 2015 11:02 pm

I'm not quite getting this from reading the documentation.

"A large variety of custom triggers can be created by deriving either from VisBaseTrigger
or VisBasePropertyTrigger"

Meaning that to create a trigger, I should edit this file or copy it or reference or?
"void Reset()
◦ This function is called whenever your script needs to be reset in the
editor. You MUST make sure to call “base.Reset()” as the first thing in
this function.
void Start()
◦ This function is called whenever your script is started running in the
game. You MUST make sure to call “base.Start()” as the first thing in
this function"

In VisBaseTrigger.cs there is a public virtual void Reset() and when you call base.Reset() as the first thing you get a syntax error because monotype doesn't contain a definition for 'Reset'.
In VisBasePropertyTrigger.cs public override void Reset()[/i] and it already begins with base.Reset() so what exactly is this referring to?

If deriving from VisBaseTrigger: void OnTriggered(...)

void OnTriggered is public abstract in both VisBaseTrigger and VisBasePropertyTrigger. You cant declare a body to this function, it's marked abstract.

So what I did is changed the abstract to virtual, and removed abstract from the class so that this script can be placed on a gameobject because the docs don't say much on this... So this allowed me to add the script to a gameobject and give the trigger event function ' onTriggered' a body to define what I wanted to happens when triggered.

It's working, but am I breaking anything by doing this? Feels wrong. It would be nice to have a trigger template of sorts...

Code: Select all

public class VisBaseTrigger : MonoBehaviour, IVisManagerTarget, IVisBaseControllerTarget

Code: Select all
public virtual void OnTriggered(float current, float previous, float difference, float adjustedDifference)
        myStaticBool = true;

Posts: 4
Joined: Sat Nov 21, 2015 1:07 am
Location: US

Return to Questions and Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

Style by Gokinstudio | Free forum hosting by ProphpBB | Software by phpBB | Report Abuse | Privacy