Haytam95
Active member
Hi
I've a question about tasks, trying to simplify how my AI tree grows.
I have this simple branch that set's a Bool Shared Variable called "canSeeTarget" true or false depending if a character can be seen.
This in code could be reduced to a single task that simply does:
Is this possible? I tried it, and all serialized fields of Can See Object called NullPointerException (Because I didn't initialized them), but if I assign them think it could work.
Is this a correct aproach? Or I'm over complicating things?
I've a question about tasks, trying to simplify how my AI tree grows.
I have this simple branch that set's a Bool Shared Variable called "canSeeTarget" true or false depending if a character can be seen.
This in code could be reduced to a single task that simply does:
C#:
public class MyCustomTask : Action
{
public SharedBool canBeSeen;
private CanSeeObject canSeeobjectTask;
// Initialize canSeeobject somewhere in start or awake.
public override TaskStatus OnUpdate() {
canBeSeen.Value = canSeeobjectTask.OnUpdate() == TaskStatus.Successful;
return TaskStatus.Sucessful
}
}
Is this possible? I tried it, and all serialized fields of Can See Object called NullPointerException (Because I didn't initialized them), but if I assign them think it could work.
Is this a correct aproach? Or I'm over complicating things?