Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

RAIN{indie} Free, Powerful, AI Engine -- Released

Discussion in 'Assets and Asset Store' started by RT_Jester, Jan 25, 2013.

  1. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    Hmm... That's pretty straightforward. When you talk about jagged animation, where are you seeing that? While walking? For all animations?
     
  2. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    With regard to changing behavior of the AI based on things happening in your code, you will probably want to do that using the AI actionContext. You can set variables with code like
    agent.actionContext.SetContextItem("daytime", true);

    Then in the behavior tree, you might have a Selector
    Selector
    - Sequencer (daytime) - precondition "daytime == true"
    - Sequencer (nighttime) - precondition "daytime != true"
     
  3. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Hello BHS,

    Thanks for posting this. Is there any way you could send us your project? I have a feeling we would really fix the problem if we saw it.

    Let me know what's possible.

    Best,
    Jester
     
  4. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    The animations aren't smooth they seem to be skipping a few frames. I thought that it was the animations so I tested just a loop walk animation and it was perfectly smooth.


    So if my script name is UniStorm (JS Version) and the variable is daytime how do I access this from RAIN? Do I set this agent.actionContext.SetContextItem("daytime", true); from within my UniStorm script?

    I can send you a small version with the character and the AI system used. The demo we're making is Skyrim like and is about 4gb. Or I can make you a demo webplayer.
     
  5. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Hello BHS,

    Thanks for the quick reply! A small sample project would work best.

    If you use meta files, then you can strip out the Library folder before zipping it up (then put it back when done and before you start unity). That saves about 50% of the space.

    Send it to jester[at]rivaltheory[dot]com

    or I can set up a Dropbox for you.

    Talk to you soon!

    Best,
    Jester
     
  6. XilenceX

    XilenceX

    Joined:
    Jun 16, 2013
    Posts:
    122
    Thanks this solution seems perfect for me, IF I can get it to work.
    The first part was pretty easy to do: I created the AttackHarness C# script and placed it on an empty game object on the player.
    With visualization checked I get these nice green cube positions now which I would like my enemies to fill.
    Sadly I have no clue how to do that, as the last 3 code parts seem to be only snippets of an existing (AI?) script.
    So where can I find this script and where in it should I put those 3 parts?
    All the scripts currently on my AI seem to be .DLLs so that's not helping.
    I would like to finish my AI for my FPS Contest entry this week, so please let me know how I can get this to work.
     
  7. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    PM Sent
     
  8. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    It's saying :
    Unknown identifier: 'agent'.

    How do I call RAIN from within my day and night script? I'm using JavaScript.
     
  9. XilenceX

    XilenceX

    Joined:
    Jun 16, 2013
    Posts:
    122
    I've just found a thread on the support forums about the AttackHarness script: http://support.rivaltheory.com/vani...on/484/is-rain-indie-the-right-tools-crowd-ai
    It's explained there that the code snippets go into 3 custom behaviour tree nodes. I was already suspecting this much and looked into the default action template. However I couldn't find anything in there that shows where the code snippets go. So could you please post the full custom behaviour scripts here, in that thread or even better yet in the documentation? I understand that takes some more space, but it would also make things a lot easier.

    Once the custom nodes are done the setup seems pretty straightforward. However I didn't understand the double release slot at the end of the suggested setup. So it would be nice to have a screenshot of the behaviour tree as well, if you've created one already. Otherwise I'll try to figure one out myself once I get the custom nodes.
    Thanks for the support.
     
  10. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Our Studio Showcase program is live! Get your game in front of thousands!

    Studio Showcase is a free program where we promote games using RAIN to thousands of players, artists, and developers that are waiting to see the next great idea. Your idea.

    $Studio-Showcase-banner-large.png

    Click the link below to get started.

    We can't wait to see your projects!

    http://bit.ly/1aN0UnQ

    Best,
    Jester
     

    Attached Files:

  11. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    We have a fix coming for the fade in/out. Although the fades are working, they require that you run your nodes in parallel. We'll make a change so that you can also get the fades to work when using sequential nodes.

    We looked closely at what's going on here. The problem you're seeing is in the animations themselves, not in RAIN. If you play the animations back slowly, or even if you remove RAIN and use a simple script to move your character while animation is playing, you will see that there are a few short lags in the leg movement. The "jitter" becomes more noticeable when the movement speed matches the animation speed, which causes the legs to become synced at certain times, but then get out of sync a bit after one of the pauses.

    I'll also suggest that you remove Unity's CharacterController and just use a capsule collider. Then switch from the AICharacterController to the AIKinematic controller. You will get the same result, but much better performance.
     
  12. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Thank you for the answer.

    I will work on switching the character controllers over. I was wondering why RAIN was affecting my performance. Thanks for the tips.

    Could you please provide an example of accessing RAIN from within a custom script? We really need to make AI affected by day and night.

    Lets say the script is called UniStorm, this is in JavaScript, during the day I'd like to set dayTime to true during the night I'd like to set nightTime to true. How can I access RAIN variables from within a JavaScript? Like set the precondition from within our UniStorm script.

    Thanks for the help.
     
  13. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    @BHS - I also noticed in your project that your Sweep3, Sweep4, and Sweep5 are below the ground. That's causing your AI to get stuck when moving. If you lift those up to ground level, he'll work correctly.

    I've got the fades working correctly, so I'll include the fix in a patch next week.
     
  14. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Thanks, and okay sound great.

    If I use a AIKinematic controller and a capsule collider my characters go through the ground. He doesn't collide with the terrain. I have collide with terrain too.

    Any idea how to fix this?
     
  15. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Hello BHS,

    We have your project all fixed up! Let me know where I can send it to. I need about 60mgs of space.

    Let me know!

    Best,
    Jester
     
  16. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    Thank you.

    Can you link it in a dropbox link so I can download it?
     
  17. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Yes,

    What email should I send it to?

    Best,
    Nick
     
  18. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,764
    You can just PM it here on the forums. Thanks
     
  19. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    All sent!

    Thanks!

    Jester
     
  20. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    I cannot figure out how to move mecanim actor by mouse click. Could someone help?
    It seems agent.MoveTarget does nothing for MecanimMove.
    What I finally did:
    Code (csharp):
    1.     RaycastHit hit;
    2.         if (Physics.Raycast (cam.ScreenPointToRay (Input.mousePosition), out hit, Mathf.Infinity, mask))
    3.         {  
    4.             if (target == null)
    5.             {
    6.                 target = mind.actionContext.GetContextItem<MoveLookTarget>("__agentMoveTarget");
    7.             }
    8.            
    9.             target.VectorTarget = hit.point;
    10.         }
    11.  
    It works, but I'm not sure if this hack is the correct way to do things.

    Also, the latest version destroys behavior tree quite often, replacing xml content with error. Maybe I'm doing something wrong?
     
  21. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    We've seen a few reports of issues with the BT Editor over the weekend. All have come in at around the same time, so we feel like the problem is triggered by something external to RAIN. Note that in almost every case, your xml behavior file will not be overwritten, even if the editor shows an error. We did find one case in which this could occur and will be releasing a patch to resolve it.

    If you do run into the problem with the behavior tree editor again, please click on the Error node and then send us the debug trace from the Unity console. It will help us figure out what's going on. Thanks!

    As for moving - the easiest way to accomplish it is

    - in your mecanim move node, set the movetarget type to variable
    - use a variable name like "movetarget"
    - in your script, you would simply put
    mind.actionContext.SetContextItem<Vector3>("movetarget", hit.point);

    that's it...
     
  22. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Thank you for help Prime, works like a charm now!
    About error, it was connected to windows update I think, no errors yet since rebooting.
     
  23. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Well, I was too fast. The error appears again, I clicked reload and it completely rewrite behavior xml with this:
    <behaviortree name="behaviortree" precondition="" repeatuntil="" debug="False"><error name="error" /></behaviortree>

    But I cannot reproduce it again, I will try to give you more details if it happen again.

    Another question.
    I have a lot of dynamically added stuff on Awake. Is it possible to bake navigation grid on Awake also (as A* project does) ?
    I've tried to use Graph Modifier, but it works quite bad, my actor stuck inside it or around quite often if mecanim does rotation nearby.
    I've tried Obstacle Avoidance Collider, but result is not stable, from time to time the same obstacle just ignored. If actor is too close and I set target just behind obstacle.
     
  24. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Montyfi,

    Thanks for the update, we just fixed this in the newest version of RAIN{indie} (which will hit the asset store as soon as it's approved by Unity). Email me jester@rivaltheory.com and I will send you over a package.

    I look forward to hearing from you!

    Best,
    Jester
     
  25. raycosantana

    raycosantana

    Joined:
    Dec 23, 2012
    Posts:
    319
    Hello! Im having a little problem, mine IA works and all but its really slow when using the Move action, changing the number inside its speed field does nothing, one user in the first page of this thread said he had the same problem and he solved it by editing the "RAINagent scripts" but I cant find such scripts and I think its a bug (because changing the number in the "speed" field should make it faster, slower or at least do something different..)

    Thanks!
     
  26. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    Speed can be controlled in a couple of places in RAIN{indie}. Your RAINAgent component has a Max Speed, which will limit how fast your AI can move in all cases. This is also the default speed if you just call Move() from code.

    If you are using a Behavior Tree, you can also set the movement speed in your Move node. The AI speed will be the minimum of that speed and your RAINAgent Max Speed. If you set the speed to a negative number in the Move node (or leave it blank) then the Move node will use the RAINAgent Max Speed.


    Hope that helps.
     
  27. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    How well does this work with procedurally generated levels? I didn't see any mention of being able to call recast refresh from code. Presumably it would work fine with levels made up of prefabs if you generated a grid for each prefab when you created them and they would still be intact when you instantiated the prefab later. Would AI be able to move from one grid to another?
     
  28. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    The NavGrid system does not work well with procedurally generated levels, nor with prefabs assembled at runtime (assuming you needed to path across them).

    The upcoming Fall release of RAIN includes the ability to create nav meshes at runtime. However, we don't yet have an automated system for linking multiple graphs together at runtime (e.g., stitching them or calculating crossover regions). So it would likely work with a procedurally generated level, but would require additional effort for tiled/assembled levels.
     
  29. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    How about if each room wasn't assembled at runtime but constructed in the editor with a generated nav grid? If you are spawning in a prefab room with nav grid and when enemies are spawned from a generic spawn pool assigning them to that particular room's navgrid it doesn't seem like it would cause problems with the current version. Limiting AI movement to the current room might not even be an issue. Our aim is to randomize which rooms are encountered in a given level rather than truly procedurally generating them completely so that room elements can be hand placed anyway (and the "rooms" are actually quite large).
     
  30. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    That would work just fine. Simply assign the navgrid to the AI at runtime (in the pathmanager) and then call pathmanager.ReInit().
     
  31. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Turn The Game On shows how to codelessly make ships fly around using RAIN AI. Thanks for making an awesome tutorial!



    If you have a RAIN video you'd like us to promote, let me know.

    Best,
    Jester
     
    Last edited: Aug 14, 2013
  32. devfo

    devfo

    Joined:
    Jul 24, 2012
    Posts:
    49
    Last edited: Aug 16, 2013
  33. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    I suspect your Move node is failing. Change your movetarget from "player position" to just "player", which is the variable you are setting in your detect node.

    Looks like there are other problems too though. Your Move will continue to run until it is right on top of the player, but it looks like you want to use the attack sensor to stop moving when you are close enough.

    Instead, I suggest you use a parallel so that your sensors and your move run at the same time.

    Parallel
    -- Detect Player
    -- Detect Player very close
    -- Selector
    ---- Move to player (precondition, very close == false)
    ---- Attack (precondition, very close == true)


    Something like that.
     
  34. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Here's a sneak peek at what we have in store for the newest version of RAIN, set to release this Fall!

    $Sneak Peek Navigation Mesh banner.jpg


    For more information on coming features, visit our website and sign up for our newsletter! http://bit.ly/16E41zB

    As always, questions/comments are welcome!

    Best,
    Jester
     
  35. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    I want to create some crowd behaviours. Each agent will want to also be able to avoid each other (think boids). Can RAIN do this style?
     
  36. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Hello SmellyDogs!

    Thanks for posting. We may do something with crowd simulation eventually, but RAIN is not built for that particular application. I would suggest taking a look at Aaron G's A* solution-- specifically his RVO. I would combine that with the other features of RAIN (behavior trees, sensors/aspects, and animation control)-- then you can have it all.

    Let me know if you need anything else!

    Best,
    Jester
     
  37. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    So lets say I just want something basic less boids oriented (for now). I would like to try something like this:

    Generate a nav mesh.
    Create 20 or 30 entities.
    For behaviour turn on avoidance.
    Have each entity pick a random point and navigate to it, repeat.
    Add on additional behaviours that take precedence over "wandering". Eg explosion occurs, run to position opposite explosion.

    Can RAIN handle all of that?
     
  38. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Smelly Dogs,

    Thanks for the follow-up. The simple answer is Yes. What you're describing is certainly possible with RAIN. We do have a Fall release coming up that will make it even easier.

    Let me know if you have more questions.

    Best,
    Jester
     
  39. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Just when I thought I was out, they pulled me back in!

    Looking forward to the new features :)

    Thanks Jester
     
  40. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Hahaha Thanks MoHoe!

    For those of you that haven't seen our list of features coming out.

    Check it out here

    Feedback is always welcome!

    Best,
    Jester
     
  41. thedreamer

    thedreamer

    Joined:
    May 13, 2013
    Posts:
    226
    if I want to make something like Sims, is Rain indie Good choice?


    Please give me a good advice
     
  42. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Hello thedreamer,

    Yes RAIN{indie} is a fantastic choice for a Sims-type game. The use of the behavior trees, navigation meshes, sensors/aspects etc. will allow you to build characters that will react in multiple situations.

    My best advice would be to check out our Fall release upcoming features http://rivaltheory.com/rainindie/upcomingfeature/ for more details.

    Let me know if this helps!

    Best,
    Jester
     
    Last edited: Sep 2, 2013
  43. thedreamer

    thedreamer

    Joined:
    May 13, 2013
    Posts:
    226
    Could we see all Upcoming Features this fall?
    This is fantastic!!

    Let's say one kind of wish more

    I hope Your efforts will lead to good results

    It is a very good product but hard to use

    Rain indie need to user friendly tutorials (Personally I need "behavior trees" tutorials ^^;;)

    It is necessary for you too. if your product want to be loved...
     
  44. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Thanks for the feedback! The Fall release of RAIN will be easier to use than ever before. We are also creating a developer program for users to create and distribute their own plug-ins for RAIN which can include behavior trees.

    We will post out more information on the upcoming features of RAIN very soon!

    In the meantime, let me know if you have any more questions!

    Best,
    Jester
     
    Last edited: Sep 3, 2013
  45. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    How can I switch Mecanim Move between Rain PathFinding and Waypoint ?
    e.g. The agent move to certain spot position using pathfinding and then change to follow waypoints.
     
  46. Prime

    Prime

    Joined:
    Jul 22, 2011
    Posts:
    39
    To switch, make sure both waypoints and navgrid are set up correctly in your pathmanager (i.e., the waypointcollection is set and the navgrid file is set). When you want to switch, just use a custom action and a little code. Use the AI.pathmanager (cast as a RAINPathManager). change useWaypointCollection to true and useNavigationGrid to false, then call ReInit().
     
  47. siegleind

    siegleind

    Joined:
    Jul 26, 2013
    Posts:
    1
    Hello, i am newbie with unity and Rain{indie}.
    i am trying to make AI that will detect Player who enter the sight sensor, keep looking at him until he goes outside the sensor, and then the AI will move to the last player position detected.

    i've tried using this simple tree and placed the player on AI Sight
    root
    |-->parallel
    |----> selector precondition seek == 0
    |---------> action detect. with repeat until failure and store the variable as playerPos2
    |---------> action assign, seek = 1
    |----> move. precondition seek == 1, move target position playerPos2

    it seems the variable playerPos2 isn't stored, so the AI won't move at all.
    i'm lost..
    Sorry for my bad English.
     
    Last edited: Sep 5, 2013
  48. RT_Jester

    RT_Jester

    Joined:
    Jul 21, 2011
    Posts:
    368
    Hello siegleind!

    Thanks for posting! Here is a tutorial Coders Expo made that shows how to do exactly what your looking for + more. The AI patrols, detects, chases, loses sight, searches, gives up, and re-patrols.

    http://www.youtube.com/watch?feature=player_embedded&v=gwnHd1ZIayY#t=2012

    Let me know if this helps!

    Best,
    Jester
     
  49. rtheprince

    rtheprince

    Joined:
    May 28, 2013
    Posts:
    25
    Hi there i just wanted to see if i could ge a little advice about whats going wrong with my AI. I followed CodersExpo tutorial for a base. But i made some changes since his was only setup for one enemy and predetermined way points. So i made the patrol way point collection be created once the enemy was spawned and gave them unique names so you could spawn multiple enemies without problems. If anyone else comes across this feel free to use this code in your projects!

    The main problem that I'm having is not with my code (as far as i can tell; no errors at run time or in Unity). I cannot get the AI to move at all. Not even during the patrol or during the chase. But the code is still running and the states are changing.

    Behavior Tree xml
    Basic Melee Setup
    Enemy Chasing
    Enemy Patrol
    Enemy Searching
     
    Last edited: Sep 10, 2013
  50. n8

    n8

    Joined:
    Mar 4, 2010
    Posts:
    147
    Hey guys. Great product, I have been using Unity for a while now and finally got over my fear of AI and dove into RAIN last week. After following one of the coder expo tuts, I was able to get my scene setup pretty well. I am creating enemy aircraft that will swarm the player and attack once in range. I have that part working, I am just running to a few issues that I was hoping to get some help with.

    1. obstacle avoidance - I have been seeing this one pop up all over this thread, but I can't tell if ppl are just setting up wrong or there is an actual error with RAIN. In my situation, I had to turn Kinematic controller to a "custom controller" and then inside of "Custom Actions" I am setting random waypoints and then moving the AI Avatar to those points. This works great and allows for really fluid movement (Rain "moveTo" was far too mechanical, but that is a question for another post), however there is zero avoidance of anything. The AI will actually just fly right through mountains or underground, to get to the waypoint. Colliders don't seem to have any affect and cause no collision whatsoever.

    Any ideas on how to get this working?
    here is the line that I am using to move to the waypoint:
    agent.Avatar.transform.Translate(0,0, (deltaTime * agent.Kinematic.MaxSpeed));
    from here I get the angle of the waypoint and then rotate into the waypoint to get the fluid movement.

    2. performance - seems like I saw this pop up earlier in the thread, but I am having the same issues. having 4-5 AI enemies (all dups of each other) absolutely trashes my fps. In fact sometimes even just having one agent will drop my fps to sub 30s. I am deploying to mobile (iOS). iPhone 5 can mostly handle it while iPad 2 just chokes and sometimes even crashes due to "memory pressure". I can't imagine the BT being that heavy as all I am doing is a simple "patrol --> chase" scenario.

    Thanks for your help, and thanks for making a good product. I look forward to hearing from you soon