So I made an elephant, but I'd like to make it so that when it is going towards a target, it uses a run animation instead of a walk animation.
Here is my current code:
private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
System.out.println("Attempting predicate...");
if (event.isMoving()) {
System.out.println("IsMoving = true!");
if (getTarget() != null) {
System.out.println("Target != null!");
event.getController().setAnimation(new AnimationBuilder().addAnimation("run", true));
} else {
System.out.println("Target is null...");
event.getController().setAnimation(new AnimationBuilder().addAnimation("walk", true));
}
return PlayState.CONTINUE;
}
event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", true));
return PlayState.CONTINUE;
}
It uses the getTarget() method from the Mob class. However, it doesn't ever use the run animation, even if it is going after a mob. It still prints "Target is null...". And, the getTarget() method returns null everytime. Does anyone know how to fix this?