News Forums RAIN General Discussion and Troubleshooting Is it possible to use RAIN's NavMesh in Unity without the AI Behavior tree?

This topic contains 1 reply, has 2 voices, and was last updated by  Sigil 1 year ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30968

    Jester
    Keymaster

    @KjartanKennedy asked:

    Is it possible to use RAIN’s NavMesh in Unity without the AI behavior tree structures?

    Thanks for the question! We will post an answer

    #30970

    Sigil
    Keymaster

    Sorry that took so long, I started one way and decided I had a better answer:

    I will go ahead and say that this is a little more advanced as we are bypassing some of the stuff RAIN sets up for you, but with that said, here you go.

    I’ll start with one of the quicker answers that works directly with RAIN. Assuming you are going to use our AI to move at least, you can replace the BasicMind on your AI with one of your own where you can do almost anything with it. By doing it this way you will get to use our navigation meshes without having to do anything crazy. Copy this into a new csharp file to get going:

    
    using UnityEngine;
    using RAIN.Core;
    using RAIN.Minds;
    using RAIN.Serialization;
    [RAINSerializableClass]
    public class MyCustomMind : RAINMind
    {
       [RAINSerializableField]
       private Transform _target;
       public override void Think()
       {
          if (_target != null)
             AI.Motor.MoveTo(_target.position);
       }
    }
    

    Once that snippet is in your project, you can select MyCustomMind from the drop down in the Mind area of the AI Rig (the head icon). So to go a little further, let’s say you have your own components you want to work with, you can change the class to be like:

    
    ...
       [RAINSerializableField]
       private MyCustomComponent _someBehaviorMaker;
       public override void Think()
       {
          Vector3 tTarget = _someBehaviorMaker.DoSomeStuffAndGiveMeATarget();
          AI.Motor.MoveTo(tTarget);
       }
    ...
    

    As long as whatever you put under [RAINSerializableField] is a Unity object this should work. Now if you want to bypass our AI altogether and just setup a Navigation Mesh and use it, that is a little more advanced and I can add that if this isn’t enough.

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

You must be logged in to reply to this topic.