[SOLVED] Hello picking troubles

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(new EnemyControl(this)); 
        myThing_phys.setPhysicsLocation(new Vector3f(x,y,z));


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();
            EnemyControl npcControl = npcSpatial.getControl(EnemyControl.class);
            if(npcControl != null){

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?

Physics has nothing to do with picking.

Most likely, your bounding shapes are messed up in your model.

1 Like

Most likely, your bounding shapes are messed up in your model.
first time I hear about this
you about bounds?

The new information in this post is that you have animation.

Picking (by default) will only work on the default pose of your model. As a test, try removing your animation, etc. and see if picking works as expected.

…and either way, always remember to apply all transforms before exporting.

1 Like

thanks i try

thanks solved

1 Like