Open
Description
I create project from hello piking tutorial
createNPC(50,0,50);
rootNode.attachChild(shootables);
private void createNPC(float x,float y,float z) {
Spatial model = assetManager.loadModel("assets/Models/test.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);
}
public void shoot(){
if(nextShoot< Instant.now().getEpochSecond()){
if(cartridges > 0){
cartridges = cartridges - 3;
shootSound.play();
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();
EnemyControl npcControl = npcSpatial.getControl(EnemyControl.class);
if(npcControl != null){
npcControl.shuted();
}
}
nextShoot = Instant.now().getEpochSecond() + 1;
}else{
clickSound.play();
}
}
}
working on desktop
https://www.youtube.com/watch?v=zbRblVPeua0
npc die after 3 piking
and not working on android
only works from a short distance
project https://disk.yandex.ru/d/TsnxnyYbahBnrw