Refactor y-pos calc. on Walker move (again)
All checks were successful
Build and Publish WASM version of demo / Build-And-Deploy (push) Successful in 18s

This commit is contained in:
Stephen Seo 2023-08-11 13:42:20 +09:00
parent 25b7dacb08
commit 46e7bcd595

View file

@ -87,15 +87,9 @@ void Walker::update(float dt, const TBBS &bbs, unsigned int width,
call_js_get_random() * ROAMING_WAIT_VARIANCE + ROAMING_WAIT_AMOUNT;
unsigned int idx = call_js_get_random() * (float)bbs.size();
float x = (float)(idx % width) - SURFACE_X_OFFSET;
float y = 0.0F;
float y = (bbs[idx].min.y + bbs[idx].max.y) / 2.0F;
float z = (float)(idx / width) - SURFACE_Y_OFFSET;
Ray downwards{.position = Vector3{x, bbs[idx].max.y + 1.0F, z},
.direction = Vector3{0.0F, -1.0F, 0.0F}};
if (GetRayCollisionBox(downwards, bbs[idx]).hit) {
y = (bbs[idx].min.y + bbs[idx].max.y) / 2.0F;
}
set_body_pos(Vector3{x, y, z});
}
}