Sibad transfix Oto. Make Oto solid?

Hallo, How I do for make solid Oto , and the player that walks doesn’t trasfix him ??

[java]
package baseCharacter;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.PhysicsControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.input.ChaseCamera;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import com.jme3.scene.shape.Box;
import com.jme3.terrain.geomipmap.TerrainLodControl;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.heightmap.AbstractHeightMap;
import com.jme3.terrain.heightmap.ImageBasedHeightMap;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
import com.jme3.util.SkyFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**

  • A walking animated character followed by a 3rd person camera on a terrain

  • with LOD.
    */
    public class Main
    extends SimpleApplication {

    private BulletAppState bulletAppState;
    //character
    private CharacterControl charactInMove;
    private Node model;
    AnimChannel chan;
    //oto
    CharacterControl charact_Oto;
    Node model_Oto;
    AnimControl control_Oto;
    AnimChannel chan_Oto;
    //terrain
    private TerrainQuad terrain;
    private RigidBodyControl terrainPhysicsNode;
    //animation
    private AnimChannel animationChannel;
    private AnimControl animationControl;
    private float airTime = 0;
    private float startX = -100;
    private float startZ = -100;
    //camera
    ChaseCamera chaseCam;
    static float walkTimeRemaining = 5f; // seconds

    public static void main(String[] args) {
    // Logger.getLogger(“”).setLevel(Level.SEVERE);
    Main app = new Main();
    app.setShowSettings(false);
    app.start();
    }

    @Override
    public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    loadingOto();
    createLight();
    createTerrain();
    createSky();

     try {
         createCharacter();
     } catch (IOException e) {
     }
    
     setupChaseCamera();
     setupAnimationController();
    

    }

    private PhysicsSpace getPhysicsSpace() {
    return bulletAppState.getPhysicsSpace();
    }

    private void loadingOto(){
    CapsuleCollisionShape capsule_2 = new CapsuleCollisionShape(3f, 4f);
    charact_Oto = new CharacterControl(capsule_2, 0.01f);
    model_Oto = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
    model_Oto.addControl(charact_Oto);
    charact_Oto.setPhysicsLocation(new Vector3f(180, 30, -100));
    rootNode.attachChild(model_Oto);
    getPhysicsSpace().add(charact_Oto);
    }

    private void createCharacter() throws IOException {
    CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f);
    charactInMove = new CharacterControl(capsule, 0.01f);
    model = (Node) assetManager.loadModel(“Models/Sinbad/Sinbad.mesh.xml”);
    model.addControl(charactInMove);
    charactInMove.setPhysicsLocation(new Vector3f(startX, 30, -100));
    rootNode.attachChild(model);
    getPhysicsSpace().add(charactInMove);
    }

    private void createLight() {
    Vector3f direction = new Vector3f(-0.1f, -0.7f, -1).normalizeLocal();
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(direction);
    dl.setColor(ColorRGBA.White);
    rootNode.addLight(dl);
    }

    private void createSky() {
    rootNode.attachChild(SkyFactory.createSky(assetManager, “Textures/Sky/Bright/BrightSky.dds”, false));
    }

    private void createTerrain() {
    Material matRock;
    //floor
    matRock = new Material(assetManager, “Common/MatDefs/Terrain/TerrainLighting.j3md”);
    matRock.setBoolean(“useTriPlanarMapping”, false);
    matRock.setBoolean(“WardIso”, true);
    // Type of structur floor
    matRock.setTexture(“AlphaMap”, assetManager.loadTexture(“Textures/Terrain/splat/alphamap2.png”));
    //heigth floor (example just horizon or witn mountain ecc)
    Texture heightMapImage = assetManager.loadTexture(“Textures/Terrain/splat/fortress512.png”);
    //type of grass
    Texture grass = assetManager.loadTexture(“Textures/Terrain/splat/grass.jpg”);
    grass.setWrap(WrapMode.Repeat);
    matRock.setTexture(“DiffuseMap”, grass);
    matRock.setFloat(“DiffuseMap_0_scale”, 64);

     Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
     dirt.setWrap(WrapMode.Repeat);
     matRock.setTexture("DiffuseMap_1", dirt);
     matRock.setFloat("DiffuseMap_1_scale", 16);
     
     Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
     rock.setWrap(WrapMode.Repeat);
     matRock.setTexture("DiffuseMap_2", rock);
     matRock.setFloat("DiffuseMap_2_scale", 128);
     
     Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.jpg");
     normalMap0.setWrap(WrapMode.Repeat);
     
     Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
     normalMap1.setWrap(WrapMode.Repeat);
     
     Texture normalMap2 = assetManager.loadTexture("Textures/Terrain/splat/road_normal.png");
     normalMap2.setWrap(WrapMode.Repeat);
    
     matRock.setTexture("NormalMap", normalMap0);
     matRock.setTexture("NormalMap_1", normalMap2);
     matRock.setTexture("NormalMap_2", normalMap2);
    
     AbstractHeightMap heightmap = null;
     try {
         heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 0.25f);
         heightmap.load();
    
     } catch (Exception e) {
         e.printStackTrace();
     }
    
    
     terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
     
     List<Camera> cameras = new ArrayList<Camera>();
     cameras.add(getCamera());
     TerrainLodControl control = new TerrainLodControl(terrain, cameras);
     terrain.addControl(control);
     terrain.setMaterial(matRock);
     terrain.setLocalScale(new Vector3f(2, 2, 2));
    
     terrainPhysicsNode = new RigidBodyControl(CollisionShapeFactory.createMeshShape(terrain), 0);
     terrain.addControl(terrainPhysicsNode);
     rootNode.attachChild(terrain);
     getPhysicsSpace().add(terrainPhysicsNode);
    

    }

    private void setupChaseCamera() {
    flyCam.setEnabled(false);
    chaseCam = new ChaseCamera(cam, model, inputManager);
    }

    private void setupAnimationController() {
    animationControl = model.getControl(AnimControl.class);
    animationChannel = animationControl.createChannel();
    }

    @Override
    public void simpleUpdate(float tpf){
    Vector3f walk = new Vector3f();
    float currentX = charactInMove.getPhysicsLocation().x;
    float currentZ = charactInMove.getPhysicsLocation().z;
    System.out.println("posizione corrente X—>>> "+ currentX);
    System.out.println("posizione corrente Z---->>> "+ currentZ);
    if (currentX < startX + 300) {
    walk.x = .2f;
    }

     if (!charactInMove.onGround()) {
         airTime = airTime + tpf;
     } else {
         airTime = 0;
     }
     if (walk.length() == 0) {
         if (!"IdleTop".equals(animationChannel.getAnimationName())) {
             animationChannel.setAnim("IdleTop", 1f);
         }
     } else {
     	charactInMove.setViewDirection(walk);
     	if(airTime&gt; .5f){
     		 if(!"RunBase".equals(animationChannel.getAnimationName())){
     			  animationChannel.setAnim("RunBase", 0.7f);
     		 }
      	}
     }
     charactInMove.setWalkDirection(walk);
    

    }

}

[/java]

The problem is you’re using the deprecated CharacterControl class. As it says in the wiki, CharacterControl only collides with “real” physics controls such as RigidBodyControl. Try using BetterCharacterControl instead.

Scuse me but I don’t find “BetterCharacterControl”
There are:

com.jme3.bullet.control.RigidBodyControl
com.jme3.bullet.control.CharacterControl
com.jme3.bullet.control.GhostControl

…etc.

:frowning: How can I do?

@ziofedora said: Scuse me but I don't find "BetterCharacterControl" There are:

com.jme3.bullet.control.RigidBodyControl
com.jme3.bullet.control.CharacterControl
com.jme3.bullet.control.GhostControl

…etc.

:frowning: How can I do?

http://hub.jmonkeyengine.org/javadoc/com/jme3/bullet/control/BetterCharacterControl.html

Are you running an old version of JME?

2012 . Now download the most recently and work. thanks very much =D

Hallo , pspeed I now use BetterCharacterControl but I have problem (new) to move my oto, watch link

http://hub.jmonkeyengine.org/forum/topic/bad-walking-oto-character/#post-248715

instead the same test here under, with controlcharacter is very ok. Where I wrong ?
Thanks in advance :slight_smile:

[java]

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.GhostControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.AmbientLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

public class WalkingCharacterDemo extends SimpleApplication implements ActionListener, AnimEventListener {

private BulletAppState bulletAppState;
private boolean left = false, right = false, up = false, down = false;
Node myCharacter;
CharacterControl myCharacter_phys;

private AnimChannel animationChannel;
private AnimChannel attackChannel;
private AnimControl animationControl;

private Vector3f walkDirection = new Vector3f(0,0,0); // stop
 
private float airTime = 0;

public static void main(String[] args) {
	WalkingCharacterDemo app = new WalkingCharacterDemo();
	app.start();
}

@Override
public void simpleInitApp() {
    activatePhysics();
    loadScene();
    lightOn();
	loadCharacter();
	createChannel();
	configureKey();
}

//load character

public void loadCharacter(){
	  CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f);
	  myCharacter_phys = new CharacterControl(capsule, 0.05f) ;
	  myCharacter_phys.setJumpSpeed(20f);
	  myCharacter =  (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
	 
	  myCharacter.addControl(myCharacter_phys);		  
	  bulletAppState.getPhysicsSpace().add(myCharacter_phys);
	  rootNode.attachChild(myCharacter);	
}


public void activatePhysics(){
  bulletAppState= new BulletAppState();
  stateManager.attach(bulletAppState);
  bulletAppState.getPhysicsSpace().enableDebug(assetManager);
}

public void loadScene(){
      // provaaaaaaa		
    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager,bulletAppState.getPhysicsSpace());	
}

public void lightOn(){
	  AmbientLight light = new AmbientLight();
	  light.setColor(ColorRGBA.White.mult(2));
	  rootNode.addLight(light);
}

public void configureKey(){
	  // configure mappings, e.g. the WASD keys
	  inputManager.addMapping("CharLeft", new KeyTrigger(KeyInput.KEY_A));
	  inputManager.addMapping("CharRight", new KeyTrigger(KeyInput.KEY_D));
	  inputManager.addMapping("CharForward", new KeyTrigger(KeyInput.KEY_W));
	  inputManager.addMapping("CharBackward", new KeyTrigger(KeyInput.KEY_S));
	  inputManager.addMapping("CharJump", new KeyTrigger(KeyInput.KEY_RETURN));
	  inputManager.addMapping("CharAttack", new KeyTrigger(KeyInput.KEY_SPACE));
	  inputManager.addListener(this, "CharLeft", "CharRight");
	  inputManager.addListener(this, "CharForward", "CharBackward");
	  inputManager.addListener(this, "CharJump", "CharAttack");
}

public void createChannel(){
	 animationControl = myCharacter.getControl(AnimControl.class);
	  animationControl.addListener(this);
	  animationChannel = animationControl.createChannel();
	  attackChannel = animationControl.createChannel();
	  attackChannel.addBone(animationControl.getSkeleton().getBone("uparm.right"));
	  attackChannel.addBone(animationControl.getSkeleton().getBone("arm.right"));
	  attackChannel.addBone(animationControl.getSkeleton().getBone("hand.right"));
	
}

@Override
public void onAnimChange(AnimControl arg0, AnimChannel arg1, String arg2) {
	// TODO Auto-generated method stub
}

@Override
public void onAnimCycleDone(AnimControl arg0, AnimChannel arg1, String arg2) {
	// TODO Auto-generated method stub
}

private void attack() {
    attackChannel.setAnim("Dodge", 0.1f);
    attackChannel.setLoopMode(LoopMode.DontLoop);
}

@Override
public void onAction(String binding, boolean value, float tpf) {
  if (binding.equals("CharLeft")) {
      if (value) left = true;
      else left = false;
  } else if (binding.equals("CharRight")) {
      if (value) right = true;
      else right = false;
  } else if (binding.equals("CharForward")) {
      if (value) up = true;
      else up = false;
  } else if (binding.equals("CharBackward")) {
      if (value) down = true;
      else down = false;
  } else 
  if (binding.equals("CharAttack"))
    attack();
}

 
public void simpleUpdate(float tpf) {
  Vector3f camDir = cam.getDirection().clone().multLocal(0.25f);
  Vector3f camLeft = cam.getLeft().clone().multLocal(0.25f);
  camDir.y = 0;
  camLeft.y = 0;
  walkDirection.set(0, 0, 0);
 
  if (left)  walkDirection.addLocal(camLeft);
  if (right) walkDirection.addLocal(camLeft.negate());
  if (up) walkDirection.addLocal(camDir);
  if (down) walkDirection.addLocal(camDir.negate());
 
  if (!myCharacter_phys.onGround()) {
      airTime = airTime + tpf;
  } else {
      airTime = 0;
  }
 
  if (walkDirection.length() == 0) {
      if (!"stand".equals(animationChannel.getAnimationName())) {
        animationChannel.setAnim("stand", 1f);
      }
  } else {
      myCharacter_phys.setViewDirection(walkDirection);
      if (airTime &gt; .3f) {
        if (!"stand".equals(animationChannel.getAnimationName())) {
          animationChannel.setAnim("stand");
        }
      } else if (!"Walk".equals(animationChannel.getAnimationName())) {
        animationChannel.setAnim("Walk", 0.7f);
      }
    }
  myCharacter_phys.setWalkDirection(walkDirection); // THIS IS WHERE THE WALKING HAPPENS
}

}

[/java]