It really depends on everything else you are doing. The method I suggest when dealing with multiple states of an actor is to use a variable that dictates what actions should be done. This will probably be an actor variable, so all actors can have different states, but essentially you mark out what states you want and assign them an integer value. Then whenever the actor should change actions, set the variable to that of the new action and the code will be able to differentiate the tasks.
state==0 might be your default coasting value
state==1 turn right
state==2 turn left
And so on..
To use this you could have a draw actor script with a switch statement dictating movement and any other variables.
- Code: Select all
switch(state)
{
case 0: // coasting
y+=3;
break;
case 1: // move right
y+=3;
x+=3;
break;
}
Another way, or you can combine both these methods, is whenever you want to reset to the default, whatever triggers this reset should set the yvelocity of the actor, that way the default movement will be yvelocity=3. If you want further or another explanation can you give the setup you currently have?