Fix movement vector in movement behave tree

This commit is contained in:
satellite 2021-08-08 14:30:03 -04:00
parent 5b3c99b2ff
commit 4966258935

View File

@ -177,7 +177,7 @@ public class MovementTree {
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector.x,0,movementVector.z).normalize().mul(velocity)));
EntityUtils.getRotation(parent).set(movementQuaternion);
//move the entity
newPosition = new Vector3d(position).add(new Vector3d(-Math.cos(movementYaw / 180.0f * Math.PI),0,-Math.sin(movementYaw / 180.0f * Math.PI)).mul(velocity));
newPosition = new Vector3d(position).add(new Vector3d(movementVector).mul(velocity));
//check/update if collision
if(!Globals.collisionEngine.checkCanOccupyPosition(Globals.commonWorldData, parent, newPosition)){
newPosition = Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData, parent, newPosition);
@ -252,7 +252,7 @@ public class MovementTree {
EntityUtils.getRotation(parent).set(movementQuaternion);
//check if can move forward (collision engine)
//if can, move forward by entity movement stats
newPosition = new Vector3d(position).add(new Vector3d(-Math.cos(movementYaw / 180.0f * Math.PI),0,-Math.sin(movementYaw / 180.0f * Math.PI)).mul(velocity));
newPosition = new Vector3d(position).add(new Vector3d(movementVector).mul(velocity));
if(!Globals.collisionEngine.checkCanOccupyPosition(Globals.commonWorldData, parent, newPosition)){
newPosition = Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData, parent, newPosition);
}
@ -330,7 +330,7 @@ public class MovementTree {
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector).mul(-1.0f).normalize().mul(velocity)));
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), movementVector);
//move the entity
newPosition = new Vector3d(position).add(new Vector3d(-Math.cos(movementYaw / 180.0f * Math.PI),0,-Math.sin(movementYaw / 180.0f * Math.PI)).mul(velocity));
newPosition = new Vector3d(position).add(new Vector3d(movementVector).mul(velocity));
if(!Globals.collisionEngine.checkCanOccupyPosition(Globals.commonWorldData, parent, newPosition)){
newPosition = Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData, parent, newPosition);
}