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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27723

    Faffrd
    Participant

    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:
    Waypoint network
    The custom action script

    
    using 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);
        }
    }
    

    root
    Action BT
    Waypointpath
    move

    • This topic was modified 1 year, 10 months ago by  Faffrd.
    #27725

    Faffrd
    Participant

    After 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.
    #27994

    CodersExpo
    Participant

    Try this….

    BT (Chicken Wander)
    ….SEQ
    …….Action
    …….PAR
    ……….WAY
    ………….Move
    ……….Animation

    Let me know how this works before you do anything drastic

    #28013

    Faffrd
    Participant

    Thanks 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!

    #28019

    CodersExpo
    Participant

    Yes, 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?

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

You must be logged in to reply to this topic.