What is the equivalent tu Unrealscript STATES?

Hi guys,

I come from UDK, and as fas as I’ve read, Unrealscript STATES are something that we will not find in C++.
What is the equivalent to such STATES in c++?

Thanks

Thanks for your help.
I was thinking Unrealscript would translate into c++ in a specific way that could be easy to move my STATES code into something similar.

Thanks twiddle.

States aren’t something natively supported in C++ in the same way that Unrealscript supported them. I’d tend to say the closest equivalent is the state machine design pattern, wherein you encapsulate the state-specific logic into a series of classes inheriting from a common parent, and have your object store a reference to the base class that you can then instantiate specific states into, to utilise virtual functions.

From a quick glance, State · Design Patterns Revisited · Game Programming Patterns seems to have a reasonable explanation of the concept.

Well the mechanism of Unrealscript states is essentially the same insofar as you are overriding functions based on the object’s state. All this means is that you actually separate your state specific stuff into an independent object that the actor has a reference to, rather than it being in the same file, which IMHO improves readability and code organisation, and potentially allows for state classes to be shared between objects that aren’t children of the same parent class.