News › Forums › Troubleshooting › Random waypoint ?
This topic contains 9 replies, has 3 voices, and was last updated by Snuffles10155 10 months, 3 weeks ago.
February 2, 2023 at 3:29 am #6772
Is it possible to randomly select a waypoint to go to on a waypoint network while an AI is patrolling on a network ? Trying to avoid an obvious pattern in patrols here.
Can you also trigger certain events to happen when they reach certain waypoints ? Eg. play an animation on Waypoint 5 ? If so how do you access this information ?February 2, 2023 at 3:10 pm #6775
I’m interested in this question too. ;>February 3, 2023 at 2:59 pm #6785
I ran into this issue myself the other day and realized that we had initially intended to make this easy, but had lost the feature somewhere along the way. That’s why waypoints can have names…
We’ll look into making some changes so you can access waypoints by name and get access to the current waypoint destination in code/BT. Right now you can tell when you reach a waypoint - it happens when your move node returns true from inside the waypoint node. You would just need to add additional nodes after the move (and have access to the current waypoint.)February 3, 2023 at 6:17 pm #6800
What do you mean by additional nodes exactly ? Do you mean add a random node after move in the behaviour tree ? Probably just drawing a blank here and its obvious what you saidFebruary 3, 2023 at 6:21 pm #6802
The waypoint nodes look like this:
To take an action after you reach the next waypoint, do this:
— ReachedWaypointactionFebruary 3, 2023 at 7:05 pm #6809
Ok that makes more sense, except the only two nodes I can create are WaypointPatrol and WaypointPath, and im using a Waypoint Network for my routes
Currently I am using waypointPatrol node for my behaviour tree and that works fine for going through all the waypoints, should I switch to waypointPath instead ? How could I then use this for random waypoint selection.
Looking at the random node trying to figure it out right now, would I have to create a custom action from that to have code that randomzies a variable which would contain which waypoint to go to ? Or is there another way I’m missing?February 4, 2023 at 3:46 am #6822
What’s the purpose of moving to random waypoints? Are you trying to actually follow the waypoint path? Or do you just want to mark world locations to choose from, and then move to one at random?February 4, 2023 at 3:32 pm #6832
I would be using it to mark world locations to choose from, but I’m not the original poster. ;>February 4, 2023 at 3:54 pm #6835
@luxeayor - In your case, you might consider using NavigationTargets instead. Their purpose is to mark world locations that you can move to by name. They work like this:
- Add a Navigation Target from the main menu. It will create an object with a NavigationTargetRig attached and drop it to ground (or closest collider) in front of the camera. In editor it looks like a single waypoint.
- Change the game object name to something relevant (e.g., “HidingPlace”)
- In the BT, you can move to the nav target by setting the name of the game object as your move target (e.g., Move Target = “HidingPlace”)February 5, 2023 at 12:42 am #6841
My goal is similar to luxeayor so sounds like that will work thanks prime
You must be logged in to reply to this topic.