If null the task GameObject is used (not working for my own scripts)

tailevi

New member
so i wrote my own script for comparison between 2 variables and the sharedGameObject variable will not take the object that uses him automatically like a Settriget task etc.


that's the code example :

BehaviorDesigner.Runtime.Tasks.Unity.UnityAnimator
{
public class ComperToMyHealth : Action
{
[Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
public SharedGameObject mySlef;


private NPC npc;
[Tooltip("The variable to compare to")]
public SharedInt compareTo;


private GameObject prevGameObject;

public override void OnStart()
{


}

public override TaskStatus OnUpdate()
{


return mySlef.Value.GetComponent<NPC>().HP.Equals(compareTo.Value) ? TaskStatus.Success : TaskStatus.Failure;

}

public override void OnReset()
{
mySlef = null;
compareTo = 0;



}
}
}
 
You can use GetDefaultGameObject to get the GameObject for the current instance. Also for future posts if you can use the [ code ] tags that would be great so it's easier to read.
 
Top