News › Forums › RAIN › General Discussion and Troubleshooting › Stopping at the last waypoint
This topic contains 4 replies, has 2 voices, and was last updated by CodersExpo 1 year, 10 months ago.
-
AuthorPosts
-
June 13, 2022 at 11:25 pm #27723
Watched the videos, and am now trying to get my chicken to wander around, like chickens tend to do. I finally got it wandering, but it seems to stop at the ends of the waypoint, I think thats whats happeneing. I know I’m missing something simple. I’m more artist than coder, so it frustrates me, and then usually quit. Took me forever to figure out how to get the chicken to use waypoints and follow along the terrain because I get frustrated and just stop messing with it.
The waypoint network:
The custom action scriptusing UnityEngine; using System.Collections; using System.Collections.Generic; using RAIN.Core; using RAIN.Action; using RAIN.Navigation; using RAIN.Navigation.Graph; [RAINAction] public class WanderChicken1L : RAINAction { public WanderChicken1L() { actionName = "WanderChicken1L"; } 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>("varMoveTo", loc); return ActionResult.SUCCESS; } public override void Stop(AI ai) { base.Stop(ai); } }
- This topic was modified 1 year, 10 months ago by Faffrd.
June 14, 2022 at 12:02 am #27725After messing with this some more, its not just on the last waypoint. It wanders some and then just stops at random waypoints, although the animation continues.
$%^%^*#$@#$$^%$^$%
/me pulls out hair
Tested agin, now that I found out you could look at your scene window and see whats going on (yeah, I’m learning as I go).
He doesnt even stop on waypoints, sometimes he just stops in the middle of going to one. I thought it might be a navmesh problem, but the navmesh looked good at the part he stoped last time.
This is usually when I say screw it, cause I have absolutly no clue what I’m doing.- This reply was modified 1 year, 10 months ago by Faffrd.
June 16, 2022 at 9:34 pm #27994Try this….
BT (Chicken Wander)
….SEQ
…….Action
…….PAR
……….WAY
………….Move
……….AnimationLet me know how this works before you do anything drastic
June 17, 2022 at 2:17 am #28013Thanks for replying. Tried again like you said above, and it seemed to work, but still did not. The chicken seemed to be going for the far right paht, but stopped in the middle. A few tests show that sometimes it will stop between going to the path, sometimes it actually gets to the path.
You curious as how this works. It randomly chooses the waypoint from one of the waypoints on the waypoint network? Then goes to the closest path and follows the path towards the waypoint? Would the names of the waypoints need to be changed to something diffrent than the them on the waypoint path (seen here with my pig on it)? Pig seems to work fine, although he just patrols. He was my first attempt at getting the trees down, making them move and such.
Do the waypoints and the paths have to be ABOVE the navmesh?
Thanks for the help!
June 17, 2022 at 4:41 am #28019Yes, you should select the waypoints and “Drop to Surface” to make sure they are on the top. Sounds like the chicken can’t cross the road because he is stuck looking for the waypoint. Does it circle?
I wrote another script for use with Navigation Path Waypoints because the random target was not always being generated on the top of the mesh when using rough terrain. Check this link for a copy…
http://rivaltheory.com/forums/topic/waypoint-path-doesnt-work/
Also, are you using the mecanim system and do you have “Root Motion” selected?
-
AuthorPosts
You must be logged in to reply to this topic.