how do i make a rest state thats moving

Non-platform specific questions.

how do i make a rest state thats moving

Postby buckdogg75 » Thu Feb 11, 2010 2:38 am

i would like to make a rest state with a velocity of y+3 or x+3 for car games, any suggestions?
buckdogg75
 
Posts: 4
Joined: Thu Feb 11, 2010 2:34 am
Score: 0 Give a positive score

Re: how do i make a rest state thats moving

Postby skydereign » Thu Feb 11, 2010 5:47 am

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?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: how do i make a rest state thats moving

Postby buckdogg75 » Thu Feb 11, 2010 6:37 am

yeah yvelocity=3; did the trick..
I'm just starting to play with this tool so i'll mess with fancier stuff a little later.
thanks for help.
buckdogg75
 
Posts: 4
Joined: Thu Feb 11, 2010 2:34 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron