State label problem

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

State label problem

Postby Cozmo » Sun Jan 09, 11 7:05 pm

So I learned about states today, just so I could use one latent function (MoveTo()) for NPC movement in MP. There're probably ways of doing this already, but I thought coding my own path nodes would be quicker / easier and would probably be less trouble on MP too, seeing as I can't find anything on it anywhere.

I'm pretty sure I understand states now, but it won't let me compile this:

Code: Select all
State Patrolling
{
   function GetMoving()
   {
      foreach AllActors(class'CozPath',cpa)
      {
         if(cpa.PathName == PathName)
         {
            if(cpa.PathPoint == PathPoint)
            {
               goto 'LabelMove';
            }
         }
      }
   }

                //Long irrelevant stuff here

   LabelMove:

      if(cpa != none)
      {
         MoveToward(cpa);
      }
}


for this reason:

Error, Label 'LabelMove' not found in this block of code.


Was I wrong assuming that I can just declare new labels? Or have I done something really silly?
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby DxPlayer » Mon Jan 10, 11 3:10 am

forgot { one line after "LabelMove:"? :p
Last edited by DxPlayer on Mon Jan 10, 11 3:10 am, edited 1 time in total.
User avatar
DxPlayer
Regular
 
Posts: 488
Joined: Sun Jan 25, 09 6:31 pm
Location: Brazil

Re: State label problem

Postby ~ô¿ô~Nobody~ » Mon Jan 10, 11 10:00 pm

Cozmo wrote:So I learned about states today, just so I could use one latent function (MoveTo()) for NPC movement in MP. There're probably ways of doing this already, but I thought coding my own path nodes would be quicker / easier and would probably be less trouble on MP too, seeing as I can't find anything on it anywhere.

I'm pretty sure I understand states now, but it won't let me compile this:

Code: Select all
State Patrolling
{
   function GetMoving()
   {
      foreach AllActors(class'CozPath',cpa)
      {
         if(cpa.PathName == PathName)
         {
            if(cpa.PathPoint == PathPoint)
            {
               goto 'LabelMove';
            }
         }
      }
   }

                //Long irrelevant stuff here

   LabelMove:

      if(cpa != none)
      {
         MoveToward(cpa);
      }
}


for this reason:

Error, Label 'LabelMove' not found in this block of code.


Was I wrong assuming that I can just declare new labels? Or have I done something really silly?


I am not THAT much familiar with states but I'm pretty sure that you can just jump to labels within a function.
The conclusion is that you cannot jump from a function somewhere into a state code.
You can call functions from state code though..
To make it work you need to restructure it.
So it looks more like..

Code: Select all
State Patrolling
{
   function GetMoving()
   {
      foreach AllActors(class'CozPath',cpa)
      {
         if(cpa.PathName == PathName)
         {
            if(cpa.PathPoint == PathPoint)
            {
               gotoState('myMoveState');
            }
         }
      }
   }
}

state myMoveState
{
 
Begin:
      if(cpa != none)
      {
         MoveToward(cpa);
      }
}


But mind that you're in another state then.
If that function GetMoving is supposed to work always, you need to make it global.. means put it outside of the state.

If you're doing MP coding.. MIND that states can be simulated but that does NOT make them auto-replicated.
Basically states on the client run independently from the states on the server.
Last edited by ~ô¿ô~Nobody~ on Mon Jan 10, 11 10:02 pm, edited 2 times in total.
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby Cozmo » Tue Jan 11, 11 1:16 am

The conclusion is that you cannot jump from a function somewhere into a state code.
You can call functions from state code though..


Ah, this makes a lot more sense now. I don't think UnrealWiki mentioned this (or I am blind) / will update it.

I just tried it the way you structured it - it's compiled now; will test it later. Thanks a lot for the help Nobody! :D
Cozmo_RPG (v1 & v2)
MPConversations - A tool for creating multiplayer RPG stuff
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 20 guests