Basically, the idea is that this script will take the given list of objects gotten from a raycast in all four directions and decide what is more important for the ai to target. In this case, the player will take precedence over a wall or block, and if it finds neither it will set it automatically to a shrine object. However the target variable doesn't get set in my tree.
using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
public class PickTarget : Action
{
public SharedGameObjectList targs;
public SharedGameObject target;
private GameObject[] targets;
private bool loopComplete = false;
public SharedGameObject shrine;
public override void OnStart()
{
targets = targs.Value.ToArray();
loopComplete = false;
}
public override TaskStatus OnUpdate()
{
for(int t = 0; t < targets.Length; t++)
{
GameObject tmp = targets[t];
switch (tmp.tag)
{
case "Player":
target.Value = tmp;
break;
case "Block":
if (target == null)
{
target.Value = tmp;
}
break;
default:
target.Value = shrine.Value;
break;
}
}
if (target == null)
{
target.Value = shrine.Value;
}
return TaskStatus.Success;
}
}
using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
public class PickTarget : Action
{
public SharedGameObjectList targs;
public SharedGameObject target;
private GameObject[] targets;
private bool loopComplete = false;
public SharedGameObject shrine;
public override void OnStart()
{
targets = targs.Value.ToArray();
loopComplete = false;
}
public override TaskStatus OnUpdate()
{
for(int t = 0; t < targets.Length; t++)
{
GameObject tmp = targets[t];
switch (tmp.tag)
{
case "Player":
target.Value = tmp;
break;
case "Block":
if (target == null)
{
target.Value = tmp;
}
break;
default:
target.Value = shrine.Value;
break;
}
}
if (target == null)
{
target.Value = shrine.Value;
}
return TaskStatus.Success;
}
}