1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

states

Discussion in 'Programming' started by Cooban, Aug 17, 2005.

  1. Cooban

    Cooban New Member

    Joined:
    Jul 13, 2005
    Messages:
    6
    Likes Received:
    0
    Hello, does anyone know if there is a function which will return character back to their previous state. For example if a character is in scout state and then suddenly changes to attack state I need a function or way of returning to the scout state again therefore having virtual memory (sort of).

    Thanks
     
  2. SuperApe

    SuperApe Registered Monkey

    Joined:
    Mar 20, 2004
    Messages:
    333
    Likes Received:
    0
    A function to do this? I don't know of one.
    There is a Actor -> bBadStateCode which should cause an Event called RecoverFromBadStateCode(). I don't know how reliable that is.
    But, it seems you could use the Event EndState() to set a BACKUP_State var so you can switch it back with your own function.
     
  3. omegabyte

    omegabyte New Member

    Joined:
    Jul 28, 2005
    Messages:
    8
    Likes Received:
    0
    You could try creating an enumeration that contains IDs for each state you have, then have a variable lastState. Then you could create your own GotoState function like this:

    Code:
    enum StateList
    {
         STATE_ATTACK,
         STATE_SCOUT,
         STATE_WHATEVER
    }
    
    var StateList lastState;
    var StateList currentState;
    
    function MyGotoState( StateList newState )
    {
         switch newState
         { 
              case STATE_ATTACK:
                   lastState = currentState;
                   currentState = STATE_ATTACK;
                   gotostate("Attack");
    
              case STATE_SCOUT:
                   lastState = currentState;
                   currentState = STATE_SCOUT;
                   gotostate("Scout");
    
              case STATE_WHATEVER:
                   lastState = currentState;
                   currentState = STATE_WHATEVER;
                   gotostate("Whatever");
         }
    }
    
    Then, after you've switched to attack mode, when you're ready to switch back to whatever the previous state was, just go MyGotoState( lastState );

    I don't think there's any explicit function built into UT that keeps track of the last state entered. You'll probably have to keep track of the state changes yourself.
     

Share This Page