[SOLVED] How to switch animations fluidly using accelerometer movement?

oscarkim

  • Posts: 28
I am finding it difficult to make the player fluidly switch to the animation that corresponds with its direction of movement e.g Left - Walking animation for when walking left. Currently the player switches animation rather sharply/instantly. Even the idle animation does not have time to show for the player is hardly ever still. I am using accelerometer for movement. I have attached the block of code i am using.

« Last Edit: March 23, 2015, 05:19:06 am by oscarkim »

sdieters

  • Posts: 2068
You should not create two of the same threads. Instead just edit the first one.

Anyway, back to the issue.
First off, you need a treshhold for your accelerometer. The reason for this is that the accslerometer is extremely sensitive and its humanly bot possible to hold your device so still Tgat the meter doesnt register a movement. So i stead of saying IF (y of .. < 0), try a small number such as 0.5. Or you can firat print the Y of accelorometer to the log to see what number would fit best.

As for the animations, you are restarting the animation each frame that your statement is true, meaning you will never get the change to see another frame but the first one. Check if the animations isnt already playing before switching to it.

Good luck!
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p

oscarkim

  • Posts: 28
Sorry for the double thread - a problem with my browser - did not see the first thread until I had posted again.

The threshold for the accelerometer worked. As for checking if the animation is'nt already playing - I do not know how to do that could you explain a bit further.
Great tutorials by the way - subscribed.

sdieters

  • Posts: 2068
Im glad you like them =)

It is easy as this:
If ((current animation for self) = not ("animation to play"))
~ set animation to "animation to play"

Good luck!
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p

oscarkim

  • Posts: 28
Thanks. The animations work fluidly now.