[SOLVED] Ghost control not working with rigidbody control

  ```  this.name = name;
    this.model = model;
    this.appState = appState;
    this.id = id;
    this.position = position;
    
    spatial = this.appState.assetManager.loadModel("Models/"+this.model+".glb");
    spatial.setName(id);
    System.out.println(position);
    this.appState.buildingNode.attachChild(spatial);
    
    CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(spatial);
   build = new RigidBodyControl(sceneShape, 0);
    spatial.addControl(build);
            
    ghost = new GhostControl(CollisionShapeFactory.createDynamicMeshShape(spatial)); 
    spatial.addControl(ghost); 
    
    this.appState.bulletAppState.getPhysicsSpace().add(ghost);

   this.appState.bulletAppState.getPhysicsSpace().add(build);
    
    build.setKinematic(true);
    
    spatial.setLocalTranslation(position.x, position.y, position.z);
ghost control not working with rigidbody control - frezzes

Which physics library (name and version) are you using?

1 Like
plugins {
    id 'application'
    id 'java'
    id "de.undercouch.download" version "5.1.0"
    id 'idea'
    id "io.github.0ffz.github-packages" version "1.2.1" // Plugin for anonymous inclusion of artifacts hosted in github package registry
}

description = 'Strategy application'

java {
    sourceCompatibility = '11'
    targetCompatibility = '11'
}

ext.jmonkeyengineVersion = '3.6.0-stable'

mainClassName = 'strategy.Strategy'
if (!hasProperty('mainClass')) {
    ext.mainClass = mainClassName
}
jar.manifest.attributes('Main-Class': mainClassName)

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    // You can read more about how to add dependencies here:
    //   https://docs.gradle.org/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies

    implementation 'org.jmonkeyengine:jme3-core:' + jmonkeyengineVersion
    implementation 'org.jmonkeyengine:jme3-desktop:' + jmonkeyengineVersion
    runtimeOnly 'org.jmonkeyengine:jme3-jogg:' + jmonkeyengineVersion
    runtimeOnly 'org.jmonkeyengine:jme3-plugins:' + jmonkeyengineVersion

    implementation 'org.jmonkeyengine:jme3-jbullet:' + jmonkeyengineVersion
    runtimeOnly 'org.jmonkeyengine:jme3-lwjgl3:' + jmonkeyengineVersion

    implementation 'com.simsilica:lemur:1.16.0'
    implementation 'com.simsilica:lemur-proto:1.13.0'
    implementation 'org.codehaus.groovy:groovy-all:2.4.15'


}

distZip {
    //having a degenerate folder within the dist zip complicates generating the other zips
    eachFile { file ->
        String path = file.relativePath
        file.setPath(path.substring(path.indexOf("/") + 1, path.length()))
    }
    includeEmptyDirs(false)
}

//See https://api.adoptium.net/v3/assets/feature_releases/11/ga?image_type=jre for jre urls
def windowsJreUrl = "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jre_x64_windows_hotspot_17.0.6_10.zip"
def linuxJreUrl = "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jre_x64_linux_hotspot_17.0.6_10.tar.gz"
def macJreUrl = "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jre_x64_mac_hotspot_17.0.6_10.tar.gz"


task downloadWindowsJre(type: Download) {
    src windowsJreUrl
    dest new File(buildDir, '/jres/windowsJre.zip')
    overwrite false
}

task downloadAndUnzipWindowsJre(dependsOn: downloadWindowsJre, type: Copy) {
    from zipTree(downloadWindowsJre.dest)
    into "${buildDir}/jres/windowsJre/"
    includeEmptyDirs(false)
    filesMatching("**") {
        it.path = it.path.replaceAll("^[a-zA-Z0-9.+-]*[/\\\\]", "jre/") //rename the top level to something standard so the rest of the script will be easier
    }
}

task buildWindowsDistribution(dependsOn: [distZip, downloadAndUnzipWindowsJre], type: Copy)
{
    group 'distribution'
    from files("${projectDir}/scripts/desktopDeployment/Strategy.bat"), zipTree(distZip.archiveFile), "${buildDir}/jres/windowsJre"
    into new File(buildDir, 'distributions/Strategy-windows')
    includeEmptyDirs false
    exclude 'bin/**' //we are adding our own run scripts, exclude the ones coming from distZip
}

task zipWindowsDistribution( dependsOn:buildWindowsDistribution, type: Zip) {
    group 'distribution'
    archiveFileName = "Strategy-windows.zip"
    destinationDirectory = file("$buildDir/distributions")
    from "$buildDir/distributions/Strategy-windows"
}


task downloadLinuxJre(type: Download) {
    src linuxJreUrl
    dest new File(buildDir, '/jres/linuxJre.tar.gz')
    overwrite false
}

task downloadAndUnzipLinuxJre(dependsOn: downloadLinuxJre, type: Copy) {
    from tarTree(downloadLinuxJre.dest)
    into "${buildDir}/jres/linuxJre/"
    includeEmptyDirs(false)
    filesMatching("**") {
        it.path = it.path.replaceAll("^[a-zA-Z0-9.+-]*[/\\\\]", "jre/") //rename the top level to something standard so the rest of the script will be easier
    }
}

task buildLinuxDistribution(dependsOn: [distZip, downloadAndUnzipLinuxJre], type: Copy)
{
    group 'distribution'
    from files("${projectDir}/scripts/desktopDeployment/Strategy.sh"){
        fileMode 0755
    }
    from zipTree(distZip.archiveFile)
    from "${buildDir}/jres/linuxJre"
    into new File(buildDir, 'distributions/Strategy-linux')
    includeEmptyDirs false
    exclude 'bin/**' //we are adding our own run scripts, exclude the ones coming from distZip
}

task zipLinuxDistribution( dependsOn:buildLinuxDistribution, type: Zip) {
    group 'distribution'
    archiveFileName = "Strategy-linux.tar.gz"
    destinationDirectory = file("$buildDir/distributions")
    from ("$buildDir/distributions/Strategy-linux"){
      include('**.sh')
      include('**/java')
      fileMode 0755
    }
    from ("$buildDir/distributions/Strategy-linux"){
        exclude('**.sh')
        exclude('**/java')
    }
}


task downloadMacJre(type: Download) {
    src macJreUrl
    dest new File(buildDir, '/jres/macJre.tar.gz')
    overwrite false
}

task downloadAndUnzipMacJre(dependsOn: downloadMacJre, type: Copy) {
    from tarTree(downloadMacJre.dest)
    into "${buildDir}/jres/macJre/"
    includeEmptyDirs(false)
    filesMatching("**") {
        it.path = it.path.replaceAll("^[a-zA-Z0-9.+-]*[/\\\\]", "jre/") //rename the top level to something standard so the rest of the script will be easier
    }
}

task buildMacDistribution(dependsOn: [distZip, downloadAndUnzipMacJre], type: Copy)
{
    group 'distribution'
    from files("${projectDir}/scripts/desktopDeployment/Strategy.command"){
        fileMode 0755
    }
    from zipTree(distZip.archiveFile) 
    from "${buildDir}/jres/macJre"
    into new File(buildDir, 'distributions/Strategy-mac')
    includeEmptyDirs false
    exclude 'bin/**' //we are adding our own run scripts, exclude the ones coming from distZip
}

task zipMacDistribution( dependsOn:buildMacDistribution, type: Zip) {
    group 'distribution'
    archiveFileName = "Strategy-mac.tar.gz"
    destinationDirectory = file("$buildDir/distributions")
    from ("$buildDir/distributions/Strategy-mac"){
      include('**.command')
      include('**/java')
      fileMode 0755
    }
    from ("$buildDir/distributions/Strategy-mac"){
        exclude('**.command')
        exclude('**/java')
    }
}

task buildAllDistributions{
    group 'distribution'
    dependsOn 'zipWindowsDistribution'
    dependsOn 'zipLinuxDistribution'
    dependsOn 'zipMacDistribution'
}

// cleanup tasks
clean.dependsOn('cleanDLLs', 'cleanDyLibs', 'cleanLogs', 'cleanSOs')
task cleanDLLs(type: Delete) {
    delete fileTree(dir: '.', include: '*.dll')
}
task cleanDyLibs(type: Delete) {
    delete fileTree(dir: '.', include: '*.dylib')
}
task cleanLogs(type: Delete) {
    delete fileTree(dir: '.', include: 'hs_err_pid*.log')
}
task cleanSOs(type: Delete) {
    delete fileTree(dir: '.', include: '*.so')
}

task fund(){
    doLast {
       java.awt.Desktop.desktop.browse "https://start.jmonkeyengine.org/#!funding=JME_DESKTOP,LEMUR,JME_JBULLET".toURI()
    }
}

Try using Minie instead. Change

implementation 'org.jmonkeyengine:jme3-jbullet:' + jmonkeyengineVersion

to

implementation 'com.github.stephengold:Minie:7.4.0'
1 Like

Thanks it works

1 Like