Transfering a Bool of a Custom Script to Invector AI FSM
Feb 15, 2019 7:33:43 GMT
Invector and tchrisbaker like this
Post by cursedereaper on Feb 15, 2019 7:33:43 GMT
Hey everybody.
I just finished to write a custom decision that gets a Bool from my programmers script. In our case it is a "bool stunned" which we used to transist our enemy object into a "stunned"-state to prevent it from attacking while deactivating its ability to walk.
I hope this is the right way to get your own Decisions into the Framework and if someone knows a better way I'd be happy about every information we can share.
I for my part want to share my knowledge so you guys get a faster start in creating custom Decisions.
First of all I think I might not made the best "improvements" to the code of my programmer because I needed to change all his scripts by adding
"using System;"
"namespace Invector.vCharacterController.AI {public Type ComponentType {get { return typeof(*Name of Script*); } } *...rest of the code...*}"
and switching from "public class *Name of Script* : MonoBehavior" to "public class *Name of Script* : vMonoBehavior, vIAIComponent"
But as far as I tested I needed to put the script into the Invector.vCharcterController.AI namespace to get a public class *name* : vMonoBehavior, vIAIComponent which was needed for the Script to communicate with the FSMBehaviour
stunned = Bool of StunTargetBehavior wich triggers if the Enemy/AI is stunned.
You could also write a script in the namespace Invector.vCharacter.AI with a public Type that returns the Type of the Script*1 that set a Bool like:
e.g. Poisoned and reduce the health over time. This could lead in you AI running away from its enemies/the player and search for a certain Item that heals poison (if you made that action)
You might still need some custom actions for something like this but you might be able to do something like the if Poisond look for Poison Remedi with everything InVector AI included. It might be possible by using the listener, trigger boxes and changeing the Detaction Tags in a way that the AI detacts Items of on a new Layer called PoisonRemedi moves to target if target is PoisonRemedi and takes it similar to the example of the AI_Action example.
*1
Have Fun. I hope this helps you guys to write custome actions including parts of your own scripts.
I just finished to write a custom decision that gets a Bool from my programmers script. In our case it is a "bool stunned" which we used to transist our enemy object into a "stunned"-state to prevent it from attacking while deactivating its ability to walk.
I hope this is the right way to get your own Decisions into the Framework and if someone knows a better way I'd be happy about every information we can share.
I for my part want to share my knowledge so you guys get a faster start in creating custom Decisions.
First of all I think I might not made the best "improvements" to the code of my programmer because I needed to change all his scripts by adding
"using System;"
"namespace Invector.vCharacterController.AI {public Type ComponentType {get { return typeof(*Name of Script*); } } *...rest of the code...*}"
and switching from "public class *Name of Script* : MonoBehavior" to "public class *Name of Script* : vMonoBehavior, vIAIComponent"
But as far as I tested I needed to put the script into the Invector.vCharcterController.AI namespace to get a public class *name* : vMonoBehavior, vIAIComponent which was needed for the Script to communicate with the FSMBehaviour
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vCharacterController.AI.FSMBehaviour
{
public class CheckIsStunned : vStateDecision
{
public override string defaultName
{
get
{
return "Is Stunned";
}
}
public override bool Decide(vIFSMBehaviourController fsmBehaviour)
{
if (fsmBehaviour.aiController != null)
{
if (fsmBehaviour.aiController.HasComponent<StunTargetBehavior>())
{
var EnemyIsStunned = fsmBehaviour.aiController.GetAIComponent<StunTargetBehavior>().stunned;
return EnemyIsStunned;
}
}
return false;
}
}
}
StunTargetBehavior = *Name of Script*stunned = Bool of StunTargetBehavior wich triggers if the Enemy/AI is stunned.
You could also write a script in the namespace Invector.vCharacter.AI with a public Type that returns the Type of the Script*1 that set a Bool like:
e.g. Poisoned and reduce the health over time. This could lead in you AI running away from its enemies/the player and search for a certain Item that heals poison (if you made that action)
You might still need some custom actions for something like this but you might be able to do something like the if Poisond look for Poison Remedi with everything InVector AI included. It might be possible by using the listener, trigger boxes and changeing the Detaction Tags in a way that the AI detacts Items of on a new Layer called PoisonRemedi moves to target if target is PoisonRemedi and takes it similar to the example of the AI_Action example.
*1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace Invector.vCharacterController.AI
{
public class NameOfYouScript : vMonoBehaviour, vIAIComponent
public Type ComponentType
{
get
{
return typeof(NameOfYouScript);
}
}
Have Fun. I hope this helps you guys to write custome actions including parts of your own scripts.