News › Forums › RAIN › General Discussion and Troubleshooting › Wandering Tutorial - Can't Get AI to move on Terrain
Tagged: AI to move
This topic contains 11 replies, has 3 voices, and was last updated by prime 1 year, 11 months ago.
-
AuthorPosts
-
January 3, 2023 at 5:25 am #6108
I got the tutorial set up and working perfectly on a plane. I followed the same steps on a flat terrain of the same size (etc.), but it won’t work. I initially tried it on a normal terrain with some slopes, but getting the AI to move at all took a full day. Today, I’ve been banging my head on the keyboard trying to get the AI to wander or not get stuck at a waypoint on a flat terrain with no success. I’ve checked and triple checked every setting against the project d/l files and everything is the same. The only difference is the use of a terrain.
On an unrelated note, the version of RAIN for d/l on the site isn’t the latest version. Not everyone works while online and this might cause some headaches for some people.
January 3, 2023 at 2:35 pm #6110If you want to send us a project, we’ll take a look and try to identify the problem.
January 4, 2023 at 1:48 am #6124Thanks! Before I send it, I want to re-trace my steps with 2.08; the update might have fixed my issue (or trying again after a day’s sleep might show me where I may have erred).
On a different note, I hope you make more videos. prime, you have a great voice and a clear way of explaining things. Your tutorial vids are certainly worth the effort for your thankful audience.
January 7, 2023 at 3:56 pm #6181I sent it along to the wordpress email.
January 7, 2023 at 5:49 pm #6184Your project works fine for me. The terrain defender isn’t moving because he’s using the wrong behavior tree.
January 8, 2023 at 12:04 am #6194The Defender isn’t the one who is supposed to be wandering. Doesn’t matter - I didn’t care what tree he used. The Attacker (on the terrain, not the plane) is the one who gets stuck, usually after a couple of waypoints.
January 9, 2023 at 2:12 am #6224Kept fiddling around with it. I guess RAIN AI’s Waypoint Networks just don’t work on terrains. Disappointing, but it’s free, right?
January 9, 2023 at 5:42 am #6227thamolas,
In the beginning(early last week) I was having a struggle with my project terrain. I started experimenting with some settings and references. I stumbled across the settings for 3D Movement & 3D Rotation. I chose a combination( I really don’t recall the specifics). I had success. Now, before this turns into a silver bullet mistakenly, I can not tell why other than that the events were during a couple of the updates. Further, the action I took was TURN ON those settings. I do in fact have those turned off now.
Kind of screwy reply, but, the point is that both friendly & enemy GO’s easily climb up steep inclines. Because I haven’t had a need to regen the NavMesh, there actually hopping up on on top of large boulders!.
So it does work. You might bring up the Waypoints clearly up in the air & then choose “Drop to Surface”. I think that one of the patches addressed the requirementg of having it on top, but, not sure.
So , keep the faith…and don’t panic like I did!
January 9, 2023 at 6:20 am #6228Thanks for the encouragement!
I’ve tried those things. No dice.
I’m working on a game that has pretty much everything but the AI done or close to done. I REALLY love the way RAIN is set up, particularly the Behavior Trees, which make a lot of sense to me and the way I think.
To finish my current project, I’m going to go with The A* Pathfinding Project - it has proper tutorials and real documentation and works right out of the box (and I don’t need particularly complex AI for the type of game I’m working on). For my next project, I’ll take another look at RAIN. Hopefully, it will have real documentation and tutorials and work properly by then. Because I really want to use it.
January 9, 2023 at 5:17 pm #6237I’ll check again. Should work.
January 9, 2023 at 5:54 pm #6239using UnityEngine; using System.Collections; using System.Collections.Generic; using RAIN.Core; using RAIN.Action; using RAIN.Navigation; using RAIN.Navigation.Graph; [RAINAction] public class TerChooseWanderLocation : RAINAction { public TerChooseWanderLocation() { actionName = "TerChooseWanderLocation"; } public override void Start(AI ai) { base.Start(ai); } public override ActionResult Execute(AI ai) { Vector3 loc = Vector3.zero; List<RAINNavigationGraph> found = new List<RAINNavigationGraph>(); do { loc = new Vector3(ai.Kinematic.Position.x + Random.Range(-8f, 8f), ai.Kinematic.Position.y, ai.Kinematic.Position.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(ai.Kinematic.Position, loc) < 2f) || (found.Count == 0)); ai.WorkingMemory.SetItem<Vector3>("wanderTarget", loc); return ActionResult.SUCCESS; } public override void Stop(AI ai) { base.Stop(ai); } }
January 9, 2023 at 5:59 pm #6240use that for your ChooseWanderLocation. The problem has nothing to do with terrain. It was two things:
1) The prior code assumed a few things about the size of your level and its global position. This assumes less. That was causing your loc to usually be way off the walkable area.
2) The OnGraph method returns true if you don’t have a graph. Your BT was running that code before the graph was ever set up, so it was always null the first time through. If you got unlucky and chose an off graph point the first time through, you could get stuck.The new code isn’t perfect, but it does require that a graph exists with both the ai and the destination on it. To truly get this right, you would need to actually calculate a path.
We may make a change to how Move works and allow it to return success/failure in some cases where the AI gets “stuck” like this. For now, ensuring the move to point is reachable will work.
-
AuthorPosts
You must be logged in to reply to this topic.