Hello, i just starting to learn Rain,i follow a tutorial from a book to make the character wander around to different point around the navigation mesh.Here my Behavior Tree:
So the Custom Action “Select Next Target” is a small script that find target around the navigation mesh,here the script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using RAIN.Action;
using RAIN.Core;
using RAIN.Navigation.Graph;
using RAIN.Navigation;
[RAINAction]
public class SelectRandomTarget : RAINAction
{
public override void Start(RAIN.Core.AI ai)
{
base.Start(ai);
}
public override ActionResult Execute(RAIN.Core.AI ai)
{
var loc = Vector3.zero;
List<RAINNavigationGraph> found = new List<RAINNavigationGraph>();
do
{
loc = ai.Kinematic.Position;
loc.x += Random.Range(-8f,8f);
loc.z += Random.Range(-8f,8f);
found = NavigationManager.Instance.GraphsForPoints(
ai.Kinematic.Position,
loc,
ai.Motor.StepUpHeight,
NavigationManager.GraphType.Navmesh,
((BasicNavigator)ai.Navigator).GraphTags);
}
while (Vector3.Distance(loc,ai.Kinematic.Position) < 2f
|| found.Count == 0);
ai.WorkingMemory.SetItem<Vector3>("TargetPoint",loc);
return ActionResult.SUCCESS;
}
public override void Stop(RAIN.Core.AI ai)
{
base.Stop(ai);
}
}
The first parallel “walk to target”,is just a animate node with walk state and the move node have the field “Move target” set to “TargetPoint(from the script),move speed set to 1.
The next parallel “Look Busy”,is just a animate node with a idle state and a timer to wait 2 second for the next target.
My problem is that, my character start to walk,but when he go the target,normally he should stop(idle) for the 2 second,but he don’t do this,it seem to be trap in a loop and continue to walk without moving..
Here i made a small video:
Anyone know what i missing?
Thank you
This topic was modified 1 year, 5 months ago by Modulo35.
This topic was modified 1 year, 5 months ago by Modulo35.