Download

What with states

Guys, how are states done in C++? I mean, I assume that we don’t have a states, so what’s the equivalent?

Thank you.

I assume you can just create an enum like :

namespace EPlayerState
{
enum Type
{
Walking,
Swimming,
Flying
};
}

And make switch that redirect to different function.

There is plenty way to do that in C++, take a look at the engine class to see how they did, but state was definitely an UnrealScript features.

@Antares
Thanks. Much clearer now. :wink:
Regards

A more powerful approach would be the State Pattern (Wikipedia). You would create an interface for your actor’s state machine and then one class for each state implementing that interface (with virtual functions). State switching then becomes a matter of swapping out instances of your state classes at run-time. This would very closely resemble the state implementations in UE3.