Iterate through list of gameObjects

NodeCanvas Forums General Discussion Iterate through list of gameObjects

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11558
    noelram
    Participant

    Suppose you want to iterate through a list a gameObjects, each of them has an script component related to the same class with attributes and methods. How to read and write these attributes and execute these methods in Node Canvas?
    Regards

    #11561
    Gavalakis
    Keymaster

    Hello,

    I’m very sorry for the late reply, but I was ill for the last couple of days.

    To do this in NodeCanvas Behaviour Trees, you just need to use the “Iterate” Decorator node.
    The Iterate Decorator, iterates a list of any type for each of it’s elements and executes the child node for each such iteration.
    The child node can then be an Action Node for example, with the “Script Control/Execute Function” Task assigned.
    In the following example, the Iterator will iterate each gameobject in the specified list and for each of such object the NavMeshAgent.SetDestination will be called.

    Iterator

    There is also an example scene making use of Iterate Decorator node included in the examples, which you can download from the Downloads sections of this website, just in case you want to see it working in actions 🙂

    Let me know if that works for you, or if you want more information.
    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.