The method runs smoothly inside the agent, but it is on the main agent that it seems it doesn't seem to pick up what's happening inside the train agent.
train.color = 1;
((Headway)train).train_2.setVisible(false);
train_2 is green train_3 is yellow train_4 is red
I even tried an alternate approach, where I set the visibility of the 3D objects (train_2,3,4) to color==color1/2/3 based on necessity. That seems to have not worked either. As all three trains become visible.
Another approach I made, from the main agent I did train.train_2.setColor(Material Name, Color) this also failed.
You need to specify which RailCars should be (in)visible. You need to add the method getCar(int i)
after the Train
agent (in your case, apparently the Headway
agent), to get the RailCar
agent that has the 3D object. The train agent should not have 3D objects representing RailCars
, let the 3D representation of a RailCar
only in the RailCar
agent.