News Forums RAIN General Discussion and Troubleshooting Fetching Move parameters from behavior tree

This topic contains 2 replies, has 2 voices, and was last updated by  Other-Jeff 6 months, 3 weeks ago.

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

    Other-Jeff
    Participant

    Hi,
    Hopefulyl small/quick question.
    We are using a custom motor which has the following AIInit

    public override void AIInit()
        {
            base.AIInit();
            Allow3DMovement = true;
            Allow3DRotation = false;
            AllowOffGraphMovement = true;
            CloseEnoughDistance = 1.3f;
            CloseEnoughAngle = 0.2f;
        }

    Our designers however want to be able to set these in the behavior tree. Currently anything set in MOVE node is
    ignored. How do i fetch those values?

    Thanks

    JK

    #39846

    Sigil
    Keymaster

    Well for CloseEnoughDistance, you need to make sure you use the MoveTarget’s CloseEnoughDistance (the move node sets that):

    ...
    // Just an example of what I meant
    public override bool IsAt(MoveLookTarget aTarget)
    {
        Vector3 tDistance = AI.Body.transform.position - aTarget.Position;
        if (!Allow3DMovement)
            tDistance.y = 0;
        return tDistance.magnitude <= aTarget.CloseEnoughDistance;
    }
    ...

    As for CloseEnoughAngle, that one should be getting set on your motor properly. The move node sets it to what it needs right before calling Move or Face and then sets it back.

    For all the remaining you can just set them to a variable in the behavior tree and check the value wherever you like in your motor. Use an expression in the behavior tree, something like “_allow3DMovement = true”, and do something like this in your motor:

    ...
    public override bool Move()
    {
        if (!MoveTarget.IsValid)
            return false;
        Allow3DMovement = AI.WorkingMemory.GetItem<bool>("_allow3DMovement");
        Allow3DRotation = AI.WorkingMemory.GetItem<bool>("_allow3DRotation");
        AllowOffGraphMovement = AI.WorkingMemory.GetItem<bool>("_allowOffGraphMovement");
        // Everything else
    }
    ...
    #39920

    Other-Jeff
    Participant

    So, we have the basics hooked up. But its really kind of obnoxious that we cant just read BT node settings off the current node.

    I imagine that wouldn’t be hard for us to add. Is there *any* way to get source access??

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

You must be logged in to reply to this topic.