News Forums RAIN General Discussion and Troubleshooting Accessing RAIN Variables

This topic contains 2 replies, has 2 voices, and was last updated by  p4martin 1 year, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36568

    p4martin
    Participant

    Hi All, very new to RAIN, and not sure what I am looking for as searches I did were fruitless so my apologies if this has been answered somewhere.

    I have an existing script that controls the health and other values of the player character. Instead of using a ragdoll, I would like to use the death and other animations from within RAIN. So my question is as follows.

    How would I go about grabbing variable values from the player health script so as to be able to trigger the death animation from inside RAIN. Also visa / versa. Grabbing variables from RAIN via script. I would assume the vars you can create in the basic memory section of the Ai is where you can create vars for get, set operations.

    I am also quite new to C# learning as I go and also using a visual scripting tool “uScript” which is able to view actions, properties and variables via “reflection”.

    Any help for the new old guy would be much appreciated as I am a visual learning and reading does not much for me without a visual example.

    Thank you all very much in advance…

    #36583

    prime
    Keymaster

    I don’t think reflection will do you much good here - you will probably have to drop into script/code.

    Interchanging information with RAIN and other Unity scripts can be done from either side - RAIN can attempt to grab information from Unity scripts, or Unity scripts can push information into RAIN.

    For your example, let’s assume you have a player health script that is a standard Unity Monobehaviour (a regular script that attaches to a game object). Let’s also assume that the script is attached to the root of the player object, and that the AI Rig is parented somewhere below that. A typical RAIN setup might be:

    Player Object (health script attached directly)
    -> AI Object (parented to Player Object) (AIRig attached directly)

    From within your health script, you could send information into RAIN like this:

    using RAIN.Core;
    AIRig tRig = gameObject.GetComponentInChildren<AIRig>();
    if (tRig != null)
      tRig.AI.WorkingMemory.SetItem<float>("currentHealth", health);

    where “health” is the health value in your script.

    #36593

    p4martin
    Participant

    Beautiful, thats what I needed to see… Learning C# is one thing, understanding (learning) API docs is another. Thank you very much…

    Awesome.

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

You must be logged in to reply to this topic.