diff --git a/src/main/java/electrosphere/entity/state/movement/MovementTree.java b/src/main/java/electrosphere/entity/state/movement/MovementTree.java index 7002453d..8fd35144 100644 --- a/src/main/java/electrosphere/entity/state/movement/MovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/MovementTree.java @@ -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); }