Announcement

Collapse
No announcement yet.

What with states

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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.
    Blog
    Debris : My commercial game made with UDK
    Scaleform with Haxe tutorial
    Scaleform with Haxe demonstration
    LeapUDK : Leap Motion Controller for UDK

    Comment


      #3
      @Antares
      Thanks. Much clearer now.
      Regards

      Comment


        #4
        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.
        Gerke Max Preussner | UE4 Programming Consultant

        Logo
        Follow me on Github | Goodreads | Linkedin | Pinterest | SlideShare | Twitter.
        Chat with me as gmpreussner on Discord.

        Comment

        Working...
        X