tutorial working correctly.
i create npc and add physics
private void createNPC(float x,float y,float z) {
Spatial model = assetManager.loadModel("assets/Models/npc.glb");
String id = getRandomString();
model.setName( id);
SphereCollisionShape sphereShape = new SphereCollisionShape(2.0f);
CharacterControl myThing_phys = new CharacterControl( sphereShape , 1.2f );
model.addControl(myThing_phys);
bulletAppState.getPhysicsSpace().add(model);
model.addControl(new EnemyControl(this));
myThing_phys.setPhysicsLocation(new Vector3f(x,y,z));
shootables.attachChild(model);
}
shoot method
public void shoot(){
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
shootables.collideWith(ray, results);
if (results.size() > 0){
Vector3f pt = results.getCollision(0).getContactPoint();
Spatial npcSpatial = (Spatial)results.getCollision(0).getGeometry().getParent().getParent().getParent();
String hit = npcSpatial.getName();
System.out.println(hit);
EnemyControl npcControl = npcSpatial.getControl(EnemyControl.class);
if(npcControl != null){
npcControl.shuted();
}
}
}
my model
getting into the model is very difficult
hand or foot selection not working
only on the chest near the head
is it because of physics?