1 year ago

#77627

test-img

Ryan Hibbs

UnitySharpNEAT How to deactivate a unit

I'm hoping that someone here is familiar with UnitySharpNEAT as I'm running into a problem I can't seem to find the solution to. I can describe it, but providing code won't really be helpful as it extends over multiple scripts. It really requires that someone already know how to use this.

I'm running a simulation where a creature must find food, or die of starvation. For the purposes of "dying", I can see two different options of how to deactivate a unit, but neither one is giving me the results I am desiring.

The first option is if the hunger reaches zero, I can do this:

IsActive = false;

The problem with using this method is that if all the units are inactivated before the end of the duration of the trial, the trial just continues running until the time is elapsed, and I don't know how to make it start a new generation when all the units are inactive. The other option is to call

DeactivateUnit()

from the base class UnitController. This Deactivates the unit, but for some reason, continues to try to perform operations on it, specifically the activate method, and results in a NullReferenceException, because it's trying to access a blackbox that has been set to null, which it shouldn't even do because that block of code is only supposed to be called if IsActive is true, but it's set to false by the DeactivateUnit() method.

All I'm looking for, is a way to deactivate a unit that has failed, by starvation or touching a wall, and if all units are deactivated, to immediately begin a new generation.

c#

unity-game-engine

neat

0 Answers

Your Answer

Accepted video resources