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.
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.