Skip to content

Commit

Permalink
fix: acceleration in motion
Browse files Browse the repository at this point in the history
  • Loading branch information
IWareQ committed Mar 18, 2024
1 parent e298f2c commit d253e94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ protected void computeEntityCollisionMotion(Entity entity) {
var ol = other.getLocation();
var direction = new Vector3f(entity.getLocation()).sub(other.getLocation(), new Vector3f()).normalize();
float distance = max(abs(ol.x() - loc.x()), abs(ol.z() - loc.z()));
float k;
float k = 0.05f * r;
if (distance <= 0.01) continue;
if (distance <= 1) {
k = (0.05f * r) * MathUtils.fastFloatInverseSqrt(distance);
k *= MathUtils.fastFloatInverseSqrt(distance);
} else {
k = (0.05f * r) / distance;
k /= distance;
}
collisionMotion.add(direction.mul(k));
}
Expand Down Expand Up @@ -235,7 +235,7 @@ protected void updateMotion(Entity entity) {
var velocityFactor = entity.isOnGround() ? GROUND_VELOCITY_FACTOR : AIR_VELOCITY_FACTOR;
var acceleration = velocityFactor * movementFactor;
if (entity.isOnGround()) {
acceleration = (float) (movementFactor * effectFactor * Math.pow(DEFAULT_FRICTION / slipperinessMultiplier, 3));
acceleration *= (float) (effectFactor * Math.pow(DEFAULT_FRICTION / slipperinessMultiplier, 3));
}

var yaw = entity.getLocation().yaw();
Expand Down

0 comments on commit d253e94

Please sign in to comment.