userData vs custom control fields best practice?

What is the reasoning behind the separation of userData and controls? In what cases should a variable be declared as a member of a control vs as userData of a spatial?

In the example case of having one type of game entity, say NPC, that all have health, movement speed etc. should these values be declared in a custom contol that also has getters/setters or should they be stored as userData of the spatial they are attached to? Why?

There is no single answer since it all depends on what you are doing.

They are tools provided, how you use them is up to you. Some things use user data more, some use controls more, some a bit of both.

A control has a callback to the render loop and usually contains code, UserData has no such thing, and its mostly really just data. Its quite different things but as zarch said how you use them is up to you.

1 Like