Hi, in the last three weeks I’ve been creating my own FPS shooter and the enemies are the zombies. So my problem is when I hit the zombie it would change the animation from “walking” to “reactionHit”, but it doesn’t change.
CODE:
private AnalogListener analogListener = new AnalogListener() { @Override
public void onAnalog(String name, float intensity, float tpf) {
if (name.equals(MAPPING_SHOOT)){
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
rootNode.collideWith(ray, results);
String zombieName = results.getClosestCollision().getGeometry().getName();
if (!zombieName.equals("Box") && !zombieName.equals("erba-geom-0") && !zombieName.equals("ID56")
&& !zombieName.equals("ID111_0") && !zombieName.equals("M4A1-geom-0")){
if (results.size() > 0){
CollisionResult target = results.getClosestCollision();
zombieAnimation("ReactionHit");
}
}
}
}
};
//This set the walking animation
Well, it simply looks like you don’t set value to variable “zombie”. It looks like magic to me.
And now that I look it even longer. You never call zombieAnimation(), you call zombieAnimation(string derp).
A little advice. To reduce complexity and increase manageability, why don’t you give the zombie as a parameter to the zombieAnimation function? Now it relies on some ambient context you need to always manage somewhere and this… will almost never work. Super tricky.