News Forums RAIN General Discussion and Troubleshooting Simple wander script

This topic contains 2 replies, has 2 voices, and was last updated by  Modulo35 1 year, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #38174


    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;
    public class SelectRandomTarget : RAINAction
        public override void Start(RAIN.Core.AI ai)
        public override ActionResult Execute(RAIN.Core.AI ai)
            var loc =;
            List<RAINNavigationGraph> found  = new List<RAINNavigationGraph>();
                loc = ai.Kinematic.Position;
                loc.x += Random.Range(-8f,8f);
                loc.z += Random.Range(-8f,8f);
                found = NavigationManager.Instance.GraphsForPoints(
            while (Vector3.Distance(loc,ai.Kinematic.Position) < 2f
                || found.Count == 0);
            return ActionResult.SUCCESS;
        public override void Stop(RAIN.Core.AI 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, 2 months ago by  Modulo35.
    • This topic was modified 1 year, 2 months ago by  Modulo35.


    Is your parallel set to succeed on ANY or on ALL? Should be ANY.



    Great now it work!

    Thank you so much!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.