News Forums General Discussion NavigationTarget to variable

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

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

    Alex3D
    Participant

    Hi all!
    This post was the question, but now it is the solution.
    How to assign existing NavigationTarget to RAIN variable in script:

    const string NEW_FIRE_POINT = "newVariable";
    NavigationTargetRig firePoint = someExistingNavigationTargetRig;
    ai.WorkingMemory.SetItem<GameObject>(NEW_FIRE_POINT, firePoint.gameObject);
    • This topic was modified 2 months ago by  Alex3D.
    • This topic was modified 2 months ago by  Alex3D.
    • This topic was modified 2 months ago by  Alex3D.
    #33603

    prime
    Keymaster

    Thanks for the post!

    A couple of issues to keep in mind:

    - The GameObject associated with a NavigationTarget does not usually represent the position of the target. If you use the variable in this way, you may not get what you want.
    - RAIN’s various movement components (Motor, Move node) recognize Navigation Targets as movement targets, so you can assign the navigation target itself to your variable.
    - You can access a navigation target from the behavior tree in an Expression as navigationtarget(“TargetName”)
    - navigation targets can be accessed by name from the global NavigationManager

    NavigationTarget tTarget = NavigationManager.Instance.GetNavigationTarget("TargetName");
    ai.WorkingMemory.SetItem<NavigationTarget>(NEW_FIRE_POINT, tTarget);
    #33617

    Alex3D
    Participant

    Exellent!

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

You must be logged in to reply to this topic.