News Forums RAIN General Discussion and Troubleshooting Custom Motor - Getting a Transform/Object reference to target

This topic contains 2 replies, has 2 voices, and was last updated by  Sprakle 2 months, 2 weeks ago.

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

    Sprakle
    Participant

    I’m working on a custom motor that is called from the behavior tree by a Move Action. Currently the motor uses

    base.MoveTarget.Position

    but I would like to improve the motor’s accuracy with some data that can be found on the target. (for predicting motion)

    Unfortunately

    MoveTarget.TransformTarget
    MoveTarget.AspectTarget

    , and similar fields are always null.

    So, is there any way to get a direct reference to a MoveTarget object?

    • This topic was modified 2 months, 2 weeks ago by  Sprakle.
    #34812

    prime
    Keymaster

    The MoveTarget is a MoveLookTarget under the hood. A MoveLookTarget can encapsulate a lot of different types of targets, including Aspect, Transform, NavigationTarget, Vector3, Kinematic, and Variable. You can tell which type your MoveLookTarget contains by checking its TargetType property. It’s possible that your MoveLookTarget is variable type, in which case VariableTarget contains the name of the variable that holds the actual target. You can use GetTargetFromVariable to get another MoveLookTarget that has a direct reference to the contents of your variable, or you can just use AI.Memory.GetItem() to grab the variable directly out of memory (assuming you know its type).

    #34814

    Sprakle
    Participant

    The MoveLookTarget was coming from a Detect action followed by a Move action. There doesn’t seem to be a way to make them give a variable target.

    However, getting the target variable from memory by name should work. Thanks for the tip!

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

You must be logged in to reply to this topic.