GetFromAgentChildren?

NodeCanvas Forums General Discussion GetFromAgentChildren?

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

    Tom Peters here!

    So GetFromAgent, assigns the component from the agent gameObject. I was wondering if there’s a GetFromAgentChildren? – I noticed if I changed the line “field.SetValue(this, newAgent.GetComponent(field.FieldType));” to use GetComponentInChildren it works fine (it also works if the component was on the agent cause GetComponentInChildren tries to get the component from the gameObject itself, if not found only then will it look in the children…)

    Not the best solution, but it is a work-around in my case.

    It’d be nice if you added this features. Maybe add GetFromAgentChildren or GetFromAgent(Children = true) or something like that.

    (Best of all solution would be to allow ‘us’ to define where to get the component by writing drawers… yet another problem that property drawers could solve elegantly if they’d been supported…)

    Thanks!

    – TP

    #9220

    It would also be nice to see a ParentObject action where you can parent instantiated objects, but most of these sort of actions are easy enough to hand roll yourself. I think the author originally made the point of saying that there are not LOADS of pre-build behaviours as it is more for connecting together your own logic, if you are having to do LOTS of very granular stuff in your BTs then chances are you are going about it wrong (imo).

    #9219
    Gavalakis
    Keymaster

    @Tom: GetFromAgent is a helper attribute to save you from having to do that yourself in ‘OnInit’ of the Task. It’s like doing this:

    protected override string OnInit(){
    animator = agent.GetComponent();
    if (!animator) return “No Animator Component on agent”;
    return null;
    }

    I think is a bit of a special case to get a component from the children of the agent as far as initializing the task for that agent goes, but I could add an optional bool argument as you suggested.



    @grofit
    : You can use the SetProperty ScriptControl action to set the parent of an object :_)
    I tend to avoid having tasks that can be performed through reflection and those Script Control tasks.

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.