Closed infinityplusb closed 4 years ago
You should cast the controller to NewAnt
to access child class methods, like this:
NewAnt antController = cast(NewAnt)ants.children[1].controller;
antController.setHome(Vector3f(0.0f, 0.0f, 0.0f));
Thanks. That works.
I already created a controller here
auto antCtrl = New!NewAnt(ant);
ant.controller = antCtrl;
Should I have set that somewhere else, or in a different way, so I don't have to keep creating controllers? Or so that I can create it once and access it whenever I want?
You can store antCtrl
in your scene. I think it's better to store controllers in an array, at the same indices with corresponding indices in ants.children
.
I'm trying to call a function I've defined in a class that inherits from a EntityController, but am having issues with the syntax.
I've instantiated a new Entity Controller as an "NPC" type character, for an ant-simulation
Within a
This all works fine, and the function
setHome
gets called correctly when I am instantiating the EntityController. This program runs and does everything correctly.However if I try to call the
setHome
function during theonUpdate
I clearly am not doing it correctly.Gives me
The code at here should compile and run (not release mode yet :S). Adding in line 142 in Simulator.d causes the error.