FLAMEGPU2 icon indicating copy to clipboard operation
FLAMEGPU2 copied to clipboard

New Agent `getID` outside of an init function

Open ptheywood opened this issue 6 months ago • 3 comments

The current documentation for host functions & conditions > Agent Creation states that:

newAgent() returns an instance of HostNewAgentAPI, this can be used like other objects to set and get a new agent’s variables via setVariable() and getVariable(). Additionally, getID() can be used to retrieve the ID which will be assigned to the new agent.

I.e. this is what you will find if you want to find how to get the ID of a new agent.

If instead of doing this in an init function, but instead doing it outside of / prior to the Simulation existing, on a flamegpu::AgentVector_Agent, the `getID() method exists, but always returns 0 (because it has not been set yet, and can't be until it is associated with the Simulation).

This could either be documented, or possible an exception thrown if this method is used prior to the instance having it's actual ID set?

ptheywood avatar Aug 12 '24 10:08 ptheywood