Store collider/trigger as variable?

DeanMarquette

New member
I don't see anything that allows me to store a collider or trigger as a game object variable so I can use it in Pursue or Evade.

How would I do something like, on trigger enter if tag = "Biggier Monster" then evade?
 
If you want to store the actual trigger as a variable then you'll need to create a new task, but the HasEnteredTrigger/Collider does allow you to store the collider's GameObject which you can then use.
 
If you want to store the actual trigger as a variable then you'll need to create a new task, but the HasEnteredTrigger/Collider does allow you to store the collider's GameObject which you can then use.
Yes I'm wanting to store a colliders game object. In the Has entered trigger action there is no Store variable option in the inspector.
 
I would expect to see something like Playermakers on trigger enter event where you can store a collider:

playmaker.PNG

BD has this same setup on other actions such as find with tag:
Capture.PNG

But there is no store value in the Has entered trigger action:
Capture2.PNG
 
In the screenshot the Other GameObject value is the entered GameObject:

Code:
        public override void OnTriggerEnter(Collider other)
        {
            if (string.IsNullOrEmpty(tag.Value) || other.gameObject.CompareTag(tag.Value)) {
                otherGameObject.Value = other.gameObject;
                enteredTrigger = true;
            }

The name could be renamed to Store Value but this was before I starting to use the generic Store Value naming scheme and didn't want to break backwards compatibility.
 
In the screenshot the Other GameObject value is the entered GameObject:

Code:
        public override void OnTriggerEnter(Collider other)
        {
            if (string.IsNullOrEmpty(tag.Value) || other.gameObject.CompareTag(tag.Value)) {
                otherGameObject.Value = other.gameObject;
                enteredTrigger = true;
            }

The name could be renamed to Store Value but this was before I starting to use the generic Store Value naming scheme and didn't want to break backwards compatibility.

Oh okay thank you, I thought that was to drag and drop a game object in there.

What would be your solution for if game object tag = enemy Or tag = food?

I'm thinking just use a Conditional Evaluator and have multiple Has Entered Task under it.
 
You could use multiple conditional tasks, but really I would stay away from tags. String comparisons are relatively slow so it's best to design the triggers in a different way (such as using layer masks) so you don't need any tags. For the Deathmatch AI Kit I don't use any tags specifically for that reason.
 
Top