From 496625893501dea283b25cb0c8931b67cec828d1 Mon Sep 17 00:00:00 2001 From: satellite Date: Sun, 8 Aug 2021 14:30:03 -0400 Subject: [PATCH] Fix movement vector in movement behave tree --- .../electrosphere/entity/state/movement/MovementTree.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); }