Fix movement vector in movement behave tree
This commit is contained in:
parent
5b3c99b2ff
commit
4966258935
@ -177,7 +177,7 @@ public class MovementTree {
|
|||||||
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector.x,0,movementVector.z).normalize().mul(velocity)));
|
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector.x,0,movementVector.z).normalize().mul(velocity)));
|
||||||
EntityUtils.getRotation(parent).set(movementQuaternion);
|
EntityUtils.getRotation(parent).set(movementQuaternion);
|
||||||
//move the entity
|
//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
|
//check/update if collision
|
||||||
if(!Globals.collisionEngine.checkCanOccupyPosition(Globals.commonWorldData, parent, newPosition)){
|
if(!Globals.collisionEngine.checkCanOccupyPosition(Globals.commonWorldData, parent, newPosition)){
|
||||||
newPosition = Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData, parent, newPosition);
|
newPosition = Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData, parent, newPosition);
|
||||||
@ -252,7 +252,7 @@ public class MovementTree {
|
|||||||
EntityUtils.getRotation(parent).set(movementQuaternion);
|
EntityUtils.getRotation(parent).set(movementQuaternion);
|
||||||
//check if can move forward (collision engine)
|
//check if can move forward (collision engine)
|
||||||
//if can, move forward by entity movement stats
|
//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)){
|
if(!Globals.collisionEngine.checkCanOccupyPosition(Globals.commonWorldData, parent, newPosition)){
|
||||||
newPosition = Globals.collisionEngine.suggestMovementPosition(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)));
|
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector).mul(-1.0f).normalize().mul(velocity)));
|
||||||
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), movementVector);
|
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), movementVector);
|
||||||
//move the entity
|
//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)){
|
if(!Globals.collisionEngine.checkCanOccupyPosition(Globals.commonWorldData, parent, newPosition)){
|
||||||
newPosition = Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData, parent, newPosition);
|
newPosition = Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData, parent, newPosition);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user