Hi!
Im shooting a ray, using the rootNode as my start for searching for geometries.
Problem is, the result does not include the zombie mesh. Only time that the ray collides
is when I hit it somewhere near the middle torso.
Why does it not react when I hit him in the head or something?
Video to show is here:
http://www.youtube.com/watch?v=qK9hMvAImQY
Heres my method for hitting zombies:
[java]public static void shoot(Vector3f start, Vector3f end, String[] avoid, int hp) {
CollisionResults results = new CollisionResults();
Vector3f dir = end.subtract(start);
Ray ray = new Ray(start, dir);
MainClass.getRoot().collideWith(ray, results);
CollisionResults results2 = new CollisionResults();
for (int x = 0; x < results.size(); x++) {
try{
String name = results.getCollision(x).getGeometry().getName();
System.out.println(name);
if (results.getCollision(x).getGeometry().getParent() != null && !results.getCollision(x).getGeometry().getParent().getName().equals("Root Node")){
name = results.getCollision(x).getGeometry().getParent().getName();
}
if (!contains(avoid,name)){
results2.addCollision(results.getCollision(x));
} else {
System.out.println("Ignoring: "+name);
}
} catch (Exception e){
//System.out.println("Null pointer in ray");
}
}
results = results2;
if (results.size() > 0) {
// The closest collision point is what was truly hit:
CollisionResult closest = results.getClosestCollision();
// Let's interact - we mark the hit with a red dot.
if (closest.getContactPoint().distance(start) <= start.distance(end)){
ZombieManager.damage(closest.getGeometry(), hp, closest.getContactPoint(),dir );
}
}
}[/java]
I print all names of the geometries given back. Tho it doesnt print when I shoot him in the head.
Tried to see if theres an expection, so I printed it in later debugging, it did not react at all.
So what am I doing wrong?