Hello, I have recently been working with adding animations into JME. I am using an analog listener to detect gamepad input to move my character. The mapping and listening work well. However, I have an issue with the animation: the animation will not play until the gamepad joysticks are released.
The code I am using in the update loop is:
if(upL1 && upR1)
{
dir = new Vector3f(upL1Val, 0, upR1Val);
channel.setAnim("Forwards", 0.50f);
System.out.println(channel.getAnimationName());
channel.setLoopMode(LoopMode.Loop);
animStartTime = System.currentTimeMillis();
}
else if(downL1 && downR1)
{
dir = new Vector3f(-downL1Val, 0, -downR1Val);
channel.setAnim("Backwards", 0.50f);
channel.setLoopMode(LoopMode.Loop);
animStartTime = System.currentTimeMillis();
}
else if(upL1 && downR1)
{
rot = -(upL1Val + downR1Val);
channel.setAnim("Left", 0.50f);
channel.setLoopMode(LoopMode.Loop);
animStartTime = System.currentTimeMillis();
}
else if(downL1 && upR1)
{
rot = downL1Val + upR1Val;
channel.setAnim("Right", 0.50f);
channel.setLoopMode(LoopMode.Loop);
animStartTime = System.currentTimeMillis();
}
The Boolean conditions (which I set to true when input is found) all run as expected. Note that the System.out.println(channel.getAnimationName()); in the first of the if statements, prints out “Forwards” whenever input from the joysticks in the forward direction is detected. The problem is that the animation does not begin until the joysticks are released, even though the channel thinks it is playing.
How can I make the animation begin to play as soon as input is detected?
Thank you very much!
–Artur Hawkwing