jMonkeyEngine / jMonkeyEngine/jmonkeyengine

HelloPicking not working on Android

Open
#1,978 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Android examples
Dominant language
Java
Stars
4.3k
Forks
1.2k
Avg merge
4d 7h
Merged PRs (30d)
14

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the picking behavior on Android and desktop using the HelloPicking tutorial. Inspect the createNPC and shoot code, especially the ray collision and parent traversal used to find the NPC. Done means picking NPCs works from the expected distance on Android as it does on desktop.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
game-dev, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.