News › Forums › RAIN › General Discussion and Troubleshooting › New version of RAIN available
This topic contains 18 replies, has 5 voices, and was last updated by TonyV125 4 days ago.
-
AuthorPosts
-
January 12, 2023 at 1:48 pm #40701
Hi, first off I realized I made a mistake, the code I’m using is from here a few posts ealier…. http://legacy.rivaltheory.com/forums/topic/walk-waypoint-network-beginner/#post-35120
But the code changes were the same… I made the changes from VectorPathNode to WaypointPathNode and now I get an out of range exception error from this line:
moveTarget.WaypointTarget = waypointSet.Waypoints[lastWaypoint];
I did a debug.log of lastWaypoint and it is oddly always returning a value of -1 although it should be a valid node number after this line:
lastWaypoint = ((WaypointPathNode)tNode.GetConnectionOut(tRandomEdge).ToNode).NodeIndex;even though a debug.log of tNode.ConnectionsOutCount.ToString() gives me legitimate values…
I do get the warning that using NodeIndex is obsolete… is that the problem?
Thx again!
January 12, 2023 at 2:54 pm #40703Yea sorta. The waypoint class changed quite a bit. It improved in many ways (a much faster closest waypoint call, can handle very large graphs now), but the deprecation made some things a little different, and I imagine I left some things out.
Here’s an updated script that you can pull your changes from. I just updated the deprecation and changed it a bit to work with the new setup (only posting the top part as the rest is the same):
public Expression WaypointNetwork = new Expression(); //either the name of the network or a variable containing a network public Expression MoveTargetVariable = new Expression(); //the variable you want to use for the output move target private MoveLookTarget moveTarget = new MoveLookTarget(); private Waypoint lastWaypoint = null; private WaypointSet lastWaypointSet = null; public override ActionResult Execute(AI ai) { if (!MoveTargetVariable.IsValid || !MoveTargetVariable.IsVariable) return ActionResult.FAILURE; WaypointSet waypointSet = GetWaypointSetFromExpression(ai); if (waypointSet == null) return ActionResult.FAILURE; if (waypointSet != lastWaypointSet) { lastWaypoint = null; lastWaypointSet = waypointSet; } if (lastWaypoint == null) { lastWaypoint = waypointSet.GetClosestWaypoint(ai.Kinematic.Position); if (lastWaypoint == null) return ActionResult.FAILURE; moveTarget.WaypointTarget = lastWaypoint; if (!ai.Motor.IsAt(moveTarget)) { ai.WorkingMemory.SetItem<MoveLookTarget>(MoveTargetVariable.VariableName, moveTarget); return ActionResult.SUCCESS; } } int tNodeIndex = lastWaypoint.Set.IndexOfWaypoint(lastWaypoint); NavigationGraphNode tNode = waypointSet.Graph.GetNode(tNodeIndex); if (tNode.ConnectionsOutCount > 0) { int tRandomEdge = UnityEngine.Random.Range(0, tNode.ConnectionsOutCount); WaypointPathNode tRandomNode = (WaypointPathNode)tNode.GetConnectionOut(tRandomEdge).ToNode; lastWaypoint = tRandomNode.Waypoint; } moveTarget.WaypointTarget = lastWaypoint; ai.WorkingMemory.SetItem<MoveLookTarget>(MoveTargetVariable.VariableName, moveTarget); return ActionResult.SUCCESS; }
January 12, 2023 at 3:33 pm #40705Works!!!!! thanks sooooo much. I’ve really missed you guys lol.
But I had to change
private Waypoint lastWaypoint = null;
to
private RAIN.Navigation.Waypoints.Waypoint lastWaypoint = null;
as it was trying to use UnityEngine.Waypoint instead in Unity 5.5.0…
January 12, 2023 at 8:25 pm #40707@Prime - It looks like I’m okay now.
I usually keep my RAIN Behavior Tree editor always open in a separate window, and that separate window was failing to load the BTs and throwing the error. I tried toggling it using the menu (RAIN > Behavior Tree Editor) and a new BT Editor opened with the BTs and the existing BT Editor crashed. It was still open (just a gray box) and I couldn’t close it, but when I left the project and went back in all was good.
In 2.1.17, trying what I did above didn’t make a difference, so I wasn’t as quick to try it again. I then just had to reassign BTs to my characters.
Thanks again! And sorry for the false alarm.
-
AuthorPosts
You must be logged in to reply to this topic.