News Forums RAIN General Discussion and Troubleshooting Custom Action – Getting the detected object

This topic contains 2 replies, has 3 voices, and was last updated by  prime 2 years, 1 month ago.

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

    CaffeinatedTech
    Participant

    Just updating my MoveToLastDetectedPos script and this is the first part I’m stuck on. I need to get the GameObject of the detected aspect.

    I used to use the following code:
    var detected = agent.actionContext.GetContextItem.<GameObject>(“detectedTarget”);

    (Hmm the code tag makes an ugly white box with white text)

    But how do I do it now? I can’t find actionContext anymore.

    #4634

    prabir
    Participant

    Hi Though i didn’t test it myself, but based on the tutorial it should be changed as bellow :-

    var detected = agent.actionContext.GetContextItem.<GameObject>(“detectedTarget”);

    to

    var detected = agent.WorkingMemory.GetItem.<GameObject>(“detectedTarget”);

    #4636

    prime
    Keymaster

    @prabir is correct. replace “actionContext” with “WorkingMemory” and use “GetItem” or “SetItem” instead of “GetContextItem” or “SetContextItem”.

    Another quick note - the Detect node in the behavior tree can now return 3 different pieces of information. The Aspect Variable will set the RAINAspect itself, not a GameObject. The Mount Point Variable will set the GameObject of the Aspect’s MountPoint. By default this is the GameObject that the Entity refers to (aka the Form). The Form Variable will return the GameObject set as the Entity Form for the detected Aspect (which might be the same as Mount Point).

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

You must be logged in to reply to this topic.