Page 1 of 1

animation+accelerometer

PostPosted: Tue Sep 20, 2011 11:27 pm
by Fojam
ok i have the accelerometer function working so i can tilt to move my character left and right. the only problem is that i can't get him to animate while he is running in a certain direction. my code for the man moving is

Code: Select all
Vector v = getAccelerometer();
    xvelocity = v.y * -70;


can anyone help?

Re: animation+accelerometer

PostPosted: Wed Sep 21, 2011 1:09 am
by skydereign
Oh, that is the problem you were having? You should have mentioned you were having problems with animations. Anyway, if the animations are in a certain order, than you can use that to your advantage, and avoid an if. Otherwise, you'll probably have to use an if.
Code: Select all
if(xvelocity>0)
{
    // ChangeAnimation to run right NO_CHANGE
}
else
{
    // ChangeAnimation to run left NO_CHANGE
}


Also it depends on if the actor can use other animations, for example jump. If so then the above won't work with the jumping, but hopefully that is enough to get you going.

Re: animation+accelerometer

PostPosted: Wed Sep 21, 2011 1:14 am
by Fojam
Thanks. Actually i figured out my original problem but i was stumped on this. Thanks for answering

Re: animation+accelerometer

PostPosted: Wed Sep 21, 2011 1:05 pm
by Game A Gogo
skydereign wrote:Oh, that is the problem you were having? You should have mentioned you were having problems with animations. Anyway, if the animations are in a certain order, than you can use that to your advantage, and avoid an if. Otherwise, you'll probably have to use an if.
Code: Select all
if(xvelocity>0)
{
    // ChangeAnimation to run right NO_CHANGE
}
else
{
    // ChangeAnimation to run left NO_CHANGE
}


Also it depends on if the actor can use other animations, for example jump. If so then the above won't work with the jumping, but hopefully that is enough to get you going.


what happens if the player is not moving? he'll keep running towards the left...

Code: Select all
if(xvelocity>0)
{
    // ChangeAnimation to run right NO_CHANGE
}
else if(xvelocity<0)
{
    // ChangeAnimation to run left NO_CHANGE
}
else
{
    //ChangeAnimation to standing still NO_CHANGE
}

Re: animation+accelerometer

PostPosted: Wed Sep 21, 2011 10:21 pm
by skydereign
Hmm, I guess. I assumed it was still just a running game, a lot of them that use tilt don't have a standing position, the tilt is just to change direction. But even then the approach to do it would have been pretty obvious, at least that was my intent. Recently, I've been trying to not do all the thinking for people I help, just enough to get them going.