Hello ,help help !
I 'm trying to move an Sinbad character from a location to Another location in the physics space or more clearly Iβm doing the AI movement, someone correct me, if I think wrong.
Now I calculate the minimal path and set the physics location in this way :
[java]
//update loop
@Override
public void simpleUpdate(float tpf) {
// player
camDir = cam.getDirection().clone().multLocal(0.6f);
camLeft = cam.getLeft().clone().multLocal(0.4f);
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());
player.setWalkDirection(walkDirection);
cam.setLocation(player.getPhysicsLocation());
//oto
moveSinbad(tpf);
}
public void moveSinbad(float tpf){
Vector3f walk = new Vector3f();
//physics position
currentX = character.getPhysicsLocation().x;
currentZ = character.getPhysicsLocation().z;
System.out.println("position Sinbad--->>> "+currentX+ " "+currentZ);
if(currentX == -340 && currentZ == 50 ){
//destination
System.out.println("********************* POSIZIONE RAGGIUNTAAAAAAAA *************************");
}
else if(!graphLand.getMininalPath().isEmpty()){
currentX = graphLand.minimalPath.getFirst().row;
currentZ = graphLand.minimalPath.getFirst().col;
//--------------------------------------------
/*
walk.x = ? <<<----- PROBLEM
walk.z = ? <<<-----
if (!character.onGround()) {
airTime = airTime + tpf;
} else {
airTime = 0;
}
if (walk.length() == 0) {
if (!"IdleTop".equals(animationChannel.getAnimationName())) {
animationChannel.setAnim("IdleTop", 1f);
}
} else {
character.setViewDirection(walk);
if(airTime> .5f){
if(!"RunBase".equals(animationChannel.getAnimationName())){
animationChannel.setAnim("RunBase", 0.7f);
}
}
}
character.setWalkDirection(walk);
*/
//-------------------------------------------------
//remove the cell occupated
graphLand.getMininalPath().removeFirst();
//set physics location
character.setPhysicsLocation( new Vector3f( currentX ,character.getPhysicsLocation().y,currentZ ) );
}
}
[/java]
The result is that the Character is moved so Iβm happy , but I donβt know how to set/modify the walkX and walkZ for walk of character??
thanks in advance