News Forums RAIN General Discussion and Troubleshooting Get value from script to Behavior Tree

This topic contains 4 replies, has 3 voices, and was last updated by  azorek 2 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5182

    azorek
    Participant

    Hello,
    I’m creating a fps game. I have script EnemyDamage which notify when enemy is hited. I would like to change value of variable gotHit in this script when enemy is taking damage to stop move animation. I created Behavior Tree witch constraint gotHit. I aded variable gotHit in basic memory. And my problem is that I cant change gotHit variable in EnemyDamage script. I tried to do it like in this tutorial:

    but in this tutorial they are using RAIN{Indie} and I’m using Rain.

    I created this script but it is not working:

    `import RAIN.Core;

    var ai : RAINAgent;

    ai = gameObject.GetComponent.<RAINAgent>(); / there is problem I think because in RAIN this script is named AIRig

    // when enemy is taking damage do this:
    ai.Agent.actionContext.setContextItem.<float>(“gotHit”, 1);`

    Thanks for help

    • This topic was modified 2 years, 1 month ago by  azorek.
    • This topic was modified 2 years ago by  azorek.
    • This topic was modified 2 years ago by  azorek.
    • This topic was modified 2 years ago by  azorek.
    • This topic was modified 2 years ago by  azorek.
    #5188

    CaffeinatedTech
    Participant

    Yeah there is no actionContext anymore, it is WorkingMemory.

    See this thread http://rivaltheory.com/forums/topic/custom-action-getting-the-detected-object/

    The RAIN upgrade tutorial actually explains it too I discovered.

    #5189

    azorek
    Participant

    Ok now I have:

     
    var agent : RAIN.Core.AI;
    function ApplyDamage(Arr : Object[]){
    agent.WorkingMemory.SetItem.<float>("gotHit", 1.0f); 

    }
    but this line is not working. How I should declare agent?

    #5198

    prime
    Keymaster

    You probably want:

    var agent : RAIN.Core.AIRig;
    function ApplyDamage(Arr : Object[])
    {
      if (agent == null)
        agent = gameObject.GetComponent.<RAIN.Core.AIRig>();
      agent.AI.WorkingMemory.SetItem.<float>("gotHit", 1.0f);
    }
    #5217

    azorek
    Participant

    Yes!! Thanks a lot!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.