Search Unity

React - Support Thread

Discussion in 'Assets and Asset Store' started by simonwittber, Jan 31, 2014.

  1. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Last edited: Feb 12, 2017
  2. Tonmeister.

    Tonmeister.

    Joined:
    Mar 30, 2013
    Posts:
    27
    Hi Simon, you have designed a great little asset and its all beginning to fall into place. So to kick off, there may be a design reason for this, but I've found that reordering the hierarchy only seems possible with decorators yet not with leafs. Is it possible to have a way of promoting or demoting branches/leafs. The drag drop feature is still very useful.

    cheers
     
  3. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Great idea. I've allowed this in the version 3.0.16 using shift-up and shift-down to re-order children. You can now also navigate the tree using arrow keys.

    Also in this update is some Mecanim support, with the SetAniState leaf node, and WithAniState decorator node.
     
  4. kiwiboys

    kiwiboys

    Joined:
    Oct 6, 2013
    Posts:
    12
    im not really an Expert on AI actually its my first try ever, but before i buy React i need to know i few things.

    1. can it be used on sprite's ? the game is completely Sprite based and no 3d models exist in the scene.

    2. can i use it for a basic 2d platformer that patrols a platform until it sights the player then follows the player and attack the player by shooting.

    3. multiple enemy Ais with different health variables etc.
     
  5. Tonmeister.

    Tonmeister.

    Joined:
    Mar 30, 2013
    Posts:
    27
    Hi,
    I personally can only answer (2) and (3) as thats exactly what I'm using it for. I've basically got Ai's patrolling platforms, and within their behaviour they have a melee attack and ranged attack and chasing down the player if sighted. Each Ai has their own health variables but use the same react behaviour. Recent update has had new mecanim functionality which is quite useful. Not sure about sprites though.
     
  6. kiwiboys

    kiwiboys

    Joined:
    Oct 6, 2013
    Posts:
    12
    thank you thats very helpful, as i am very new to the game programing and AI world
    ~kiwi~
     
  7. nickdep

    nickdep

    Joined:
    Feb 7, 2014
    Posts:
    1
    Hi mate

    Bought React, just started working with it, going great so far. UI designer could be better... however it's 'use-able'. My question is on the 'Mutating Selector' is this the same as a 'Priority Selector'? As per this article http://www.altdevblogaday.com/2011/02/24/introduction-to-behavior-trees. They sound similar in theory however not sure if I should be using it as a 'Priority Selector'. Any example scripts of implementing a 'Priority Selector' using the framework?

    Thanks in advance
    Nick
     
  8. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    After reading that article, I'm pretty sure the term 'Priority Selector' is just a regular Selector in the case of React.

    The Mutating Selector in React will actually re-order or re-prioritise its children. You could use it to always try the most recently failed or most recently successful child first, before all others. This could be useful for trying different attack sequences, for example.

    Also, if you have specific issues with the UI please let me know, it is constantly under review and being improved where possible.
     
  9. GeorgeAmos

    GeorgeAmos

    Joined:
    Sep 17, 2013
    Posts:
    16
    Hi Simon,

    I am using React and I stumbled into some issue:

    The issue is sometimes the character stops forever.

    This is the tree that produces the above issue:
    I applied React to my character and also I applied to my character my script "SimpleReactWalkToHouse".
    After "Can I See House" becomes TRUE, it goes to the next node in the SEQUENCE and calls the function "Move to House Position". This works fine.

    The only issue with this tree is that after random some time, unexpectedly the character stops in a random place and doesn't leave that position. I can see in the console the debug.log that React is calling in a loop "Can I see the house" function, but the character just doesn't move anymore, like it did before.

    $React_1m.PNG
     
    Last edited: Feb 9, 2014
  10. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Hi George, is it possible that you email me the project source so I can help debug the issue? (simonwittber@differentmethods.com)
     
  11. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Hi George, I've looked over your code and can see some problems. It seems you're not using the new WithAnimState node as it was intended.

    The WithAniState sets a flag on the Animator component, then returns to previous value once the child has finished. This means that you have to have a boolean set up on your mecanim graph which React will turn on and off. React won't start or stop an animation for you, at the moment it will only change flags on the mecanim graph.

    The hint that this was happening is the warning in the console log:

    "Parameter 'Hash -1424766026' does not exist."

    Which means you're trying to access a variable on the animator which does not exist.
     
  12. GeorgeAmos

    GeorgeAmos

    Joined:
    Sep 17, 2013
    Posts:
    16
    Hi Simon,

    Thank you for the reply.

    Even if I take out the WithAniAction, and leave just the MoveToRandomPos, the characters stop after some random time.

    Yes, I know, the animations usage in my code is wrong.

    I am thinking to create functions to set the animation (or the character speed) and group them in pairs with the action.

    e.g.:
    Code (csharp):
    1.  
    2. Sequence
    3. +-------Sequence
    4. |         +----- SetAnimWalkandSpeed
    5. |         |
    6. |         +------MoveToRandomPos
    7. |
    8. |
    9. +--------Sequence
    10. |         +-----SetAnimIdleAndSpeed0
    11. |         |
    12. |         +----- Sleep 2
    13.  
    I think the above React-Tree might work, but please correct me if it is totally wrong. (this way I don't have to modify the mecanim graph and I can use also the legacy anim, in my opinion)
     
  13. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    I've discovered the bug! Fortunately it is a bug in the demo, not in React itself. In SimpleEnemy.cs, the MoveToRandomPos is not failing correctly when a path cannot be found.

    Change this line:

    Code (csharp):
    1.  
    2. if (agent.pathStatus == NavMeshPathStatus.PathPartial) {
    3.     yield return NodeResult.Continue;  
    4. }
    To this:

    Code (csharp):
    1.  
    2. if (agent.pathStatus == NavMeshPathStatus.PathPartial) {
    3.     yield return NodeResult.Failure;   
    4. }

    BTW, I found this using the React Debug window, I selected the agent that was not moving then saw his state was stuck in the MoveToRandomPos action.
     
    Last edited: Feb 11, 2014
  14. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    138
    Hey there, I've purched this asset recently and I'm trying to code a simple tree that moves right and left based on the player's X position. This is my code:

    Code (csharp):
    1.     using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using React;
    5.  
    6. using Action = System.Collections.Generic.IEnumerator<React.NodeResult>;
    7.  
    8. public class EnemyAI : RaycastCharacterInput {
    9.  
    10. public Transform player;
    11.     private Transform me;
    12.     public float MaxX;
    13.     private int movingDirection;
    14.  
    15.     private EnemyAnimator Animator;
    16.     // Use this for initialization
    17.     void Awake () {
    18.         NoInput = false;
    19.         NoJump = false;
    20.         Animator = GetComponentInChildren<EnemyAnimator>();
    21.         me = this.transform;
    22.     }
    23.  
    24.     public bool XPositionLess () {
    25.         if (player.position.x < me.position.x) {
    26.             if (Mathf.Abs (me.position.x - player.position.x)   < MaxX) {
    27.                 return true;
    28.             }
    29.         }
    30.         return false;
    31.     }
    32.  
    33.     public Action MoveLeft()
    34.         {
    35.             while(true) {
    36.                 yield return NodeResult.Continue;
    37.                 x = -0.5f;
    38.             movingDirection = -1;
    39.             if(Mathf.Abs (me.position.x - player.position.x)    > MaxX) {
    40.                     yield return NodeResult.Success;   
    41.                 }
    42.             }
    43.         }
    44.  
    45.  
    46. }
    47.  
    And this is my tree:

    $f793a02abfb4abc89c19ad003f94bdb7.png

    This should move the enemy left when I'm to the left of the player by a certain range specified by MaxX, however nothing happens. I even checked the React Debugger and I see nothing.
     
  15. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Looking at your MoveLeft Action code, it doesn't seem to have any code for moving the transform?

    If nothing is happening when you have this item selected in the debugger, make sure you've got a Reactor component on the GameObject and have assigned the AI asset you have created to the correct field on this component in the inspector.
     
  16. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    138
    The code is an input for another class. I've tested it and it works if I put the code into update, so its not that that's the problem. I have the Reactor component along with the components it uses attached to the gameobject as well so I have no idea what the problem could be.

    Edit: It must be something to do with my tree, because I edited the tree to be a parallel and it worked.
     
    Last edited: Feb 11, 2014
  17. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    This looks pretty nifty, I've just started doing some research into behavior trees and after listening to Alex Champandard's presentation on 2nd generation behave trees I was curious what model of BT React falls under.

    Trying to wrap my head around event driven BT's and if something like this could easily be implemented in Unity and how much better the performance would be than a traditional polling style BT. I imagine having the ability to specify a selector as being an event receiver(an suspended until it receives that event) would allow you to run both a polling/event BT model at same time?

    Very new to this so if this makes no sense my apologies.
     
  18. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228

    That's actually a hard question to answer, as React uses coroutines, which don't map exactly to the 1st gen pattern.

    IMHO, the editor is actually the more important part of the system, as that is where the design and productivity improvements are made. The actual implementation which runs the BT should be able to be changed independently of the BT design itself. A hybrid approach will be needed in Unity, as many parts of the Unity API (such as animation) need to be polled, as there is not enough event support.

    React has a neat feature where you can choose to tick the BT at an interval, rather than every frame, however when it _needs_ to run every frame, in order to check for animation state, or run an action, it will do so automatically.
     
  19. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    I was thinking with something like animation you can still fire off an animation event at various stages of the animation? (although this is new with 4.3 I believe)

    Anyways sounds great, will be picking it up and playing with it, thanks for quick response.
     
  20. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    I grabbed the v4 update and it seems to need UniExtensions. It turns out that it was just a using reference that wasn't needed. Might want to clean that up.
    It's in ReactEditor.
     
  21. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Oh gee how did I miss that! Thanks for the heads-up, fixed in 4.0.1.
     
  22. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Last edited: Mar 1, 2014
  23. andrydeen

    andrydeen

    Joined:
    Aug 11, 2012
    Posts:
    37
  24. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
  25. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Hi there,

    I'm liking how streamlined React is to use. I think the debugger is really helpful, but have a question:

    The debugger seems to show that, with a tick interval of 0, conditions in my tree take two frames to return the correct value. In frame 1, they are shown as [RUNNING], in frame 2 as [SUCCESS] or [FAILURE], and then in frame 3 the next condition or node becomes [RUNNING]. The result is that if I have a sequence of, say, five conditions, then it takes ten frames to get through them all.

    ????

    Shouldn't conditions return their result immediately?
     
  26. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    I have been waiting for someone to ask this!

    In the editor, they will take two ticks to return, specifically so that you can see them in the debugger!

    When you build your game, they will return immediately instead, taking just one tick. I think you can see this in the Condition.cs file, where there is a #if UNITY_EDITOR directive to control this behaviour.
     
  27. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Phew! Glad to hear it.
     
  28. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
    Great asset.

    I do have one issue - timing. I can't find a replacement for Time.deltaTime in React. Since my move node isn't called on every update, my move functions are "jerky" at best. Can you provide a React.DeltaTime property which would provide the delta time since this node was last called?
     
  29. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Great idea. Will add this in for the next update.
     
  30. Lance9527

    Lance9527

    Joined:
    Jul 4, 2012
    Posts:
    12
    Hi, I just purchased React and downloaded v4.0.5. The demo1 seems broken. And I can not understand how to use CallSubTree. Where is [Library.UntilCanSeePlayer]? Can I call subtree located in another asset? Thanks!
     
  31. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,349
    Hi,

    Is it possible to have the asset in email, since i cant download it from Unity because it requires 4.5 and i have 4.3.4.

    Thanks
     
  32. alvivar

    alvivar

    Joined:
    Aug 7, 2012
    Posts:
    16
    Hi,
    I'm upgrading to the latest React version, but I have several Reactable files (the old format).

    What's the workflow for upgrading? I tried to copy the json data from the old reactable file into the new React component, but the React editor stop working (freezes and don't allow modifications).

    Is there something I'm missing?

    Thanks in advance.
     
  33. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    Hi! Please send through your JSON data to support@differentmethods.zendesk.com and I'll work out what is going wrong for you.

    -Sw.
     
  34. Kalmak

    Kalmak

    Joined:
    Nov 15, 2008
    Posts:
    52
    Hi Simon

    is there any eta on some possible docs or tutorials on the new system?