Integration with Rain{indie}

Hello, I cant find informations about Astar pro integrtion with Rain AI solution, it use the unity default pathfinding, is it easy to make it use A*pathfinding ?
someone have worked on this and can share some experience?

I haven’t used Rain{AI}, so I cannot help you there. Perhaps someone else on this forum has used it, but there is no official support for it.

Yes, it is possible. I have integrated. As I am quite busy this month. Hopefully I can share code with the community later.

willing to see this masterpiece hehe

Awesome… Im stoked to see this

Cool. Would also like to see it :slight_smile:

I’m not sure exactly how to integrate it properly (?), but when I did it I created a custom action and ensured I set a variable in the tree as the target (WalkTarget in my case).
Then the script that the custom action pointed to would grab the gameobject and pass it into the Target for the pathfinding AI script.

The code below is what I used.
Legend:
BTHelper: just a field container for all the variables I use in the behavior tree, as I like them all in one place.
UnitLocomotion: my Pathing script, AIPath will probably work too if you make sure you handle the condition of no target.

Hope this helps, feel free to re-use, no credit necessary.

`using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using RAIN.Core;
using RAIN.Action;

public class WalkToTarget : Action
{

private BTHelper helper;
private UnitLocomotion pathFinder;
public WalkToTarget()
{
    actionName = "WalkToTarget";
}

public override ActionResult Start(Agent agent, float deltaTime)
{
    helper = agent.Avatar.GetComponent<BTHelper>();
    pathFinder = agent.Avatar.GetComponent<UnitLocomotion>();
    pathFinder.MoveTo(helper.WalkTarget.gameObject);
    return ActionResult.RUNNING;
}

public override ActionResult Execute(Agent agent, float deltaTime)
{
    helper = agent.Avatar.GetComponent<BTHelper>();
    if (!pathFinder.IsAtTarget) return ActionResult.RUNNING;
    pathFinder.IsAtTarget = false;

    return ActionResult.SUCCESS;
}

public override ActionResult Stop(Agent agent, float deltaTime)
{
     return ActionResult.SUCCESS;
}

}`

I have integrated AStarPathfinding (http://arongranberg.com/astar/) into RAIN 2.x, I would like to share to the public.

RAIN 2.0.6.2217 + AStarPathfinding 3.2.5.1 Free + Unity 4.2.x
https://dl.dropboxusercontent.com/u/9322397/RAIN/RAIN_Mecanim_AStar.zip

Thank you but the link is invalid!

sorry, fixed the link above.

This would be really useful for my game, but when I import it and overwrite the existing RAIN files, I get some compile errors, all in JsonSerializer.cs. They are all namespaces or types that cannot be found, including ‘Ionic’, ‘Zipfile’, and ‘Zipentry’. Is anyone else having this problem? Thanks!

After some googling, I installed Ionic.Zip.dll into my assets folder, which got rid of those compiling errors… and created 85 more. I’m starting to regret installing this package without backing up my project.

Ionic related Files is used for AStarPathfinding, RAIN files shouldn’t have problem. Btw, if you are using RAIN 1.x, it is recommended not to upgrade to 2.x directly…it is disaster…

Hi yuewah, Would it be possible to update this to the new version or perhaps guide us of what needs to be modified?

Aron, I hardly see how this is solved as its not working with the latest version of Rain and A* cant pinpoint where the error is coming from but if someone can fix it would be great as this is a great asset combined with A*

Here are the errors I am getting just in case a good Samaritan decides to reply :slight_smile:

Assets/AstarNavigator.cs(26,34): error CS0115:RAIN.Navigation.AstarNavigator.ReInit()’ is marked as an override but no suitable method found to override

Assets/AstarNavigator.cs(46,44): error CS0115: `RAIN.Navigation.AstarNavigator.GetNextPathPosition(bool)’ is marked as an override but no suitable method found to override

Assets/AstarNavigator.cs(51,44): error CS0505: RAIN.Navigation.AstarNavigator.GetNextPathWaypoint(bool, RAIN.Motion.MoveLookTarget)': cannot override becauseRAIN.Navigation.RAINNavigator.GetNextPathWaypoint(bool, bool, RAIN.Motion.MoveLookTarget)’ is not a method

Assets/AstarNavigator.cs(69,34): error CS0505: RAIN.Navigation.AstarNavigator.GetPathToMoveTarget(out RAIN.Navigation.Pathfinding.RAINPath)': cannot override becauseRAIN.Navigation.RAINNavigator.GetPathToMoveTarget(bool, out RAIN.Navigation.Pathfinding.RAINPath)’ is not a method

Assets/AstarNavigator.cs(80,38): error CS0505: RAIN.Navigation.AstarNavigator.GetPathTo(UnityEngine.Vector3, int, out RAIN.Navigation.Pathfinding.RAINPath)': cannot override becauseRAIN.Navigation.RAINNavigator.GetPathTo(UnityEngine.Vector3, int, bool, out RAIN.Navigation.Pathfinding.RAINPath)’ is not a method`

@ninjapps

Looking at the error messages: that doesn’t look like anything to do with the interaction between the A* Pathfinding Project and that system. It rather looks like the package is not compatible with the version of RAIN that you are using. It looks like the class that AstarNavigator.cs inherits from has changed a lot since no methods that the script tries to override seem to exist, so the AstarNavigator script would need to be updated, if you are lucky only the methods need to be renamed.

RAIN 2.0.6.2217 works according to @yuewah

Thanks Aron,

Yes that what I assumed, Obviously its not A* just wish someone updates this as it would give my project a boost. I will reach on the Rain forum to see if we can update this. Thanks!

Hi Aron,

I have fixed the issue thanks to Prime of Rival Theory who hinted what might could have been the issue. Turns out it was some missing signatures and deprecated methods.

Here is the script for those who need it :slight_smile:

http://rivaltheory.com/forums/topic/custom-navigator-for-a-pathfinding-project/page/2/#post-36182