control fix

This commit is contained in:
onezplpl 2024-07-23 15:13:44 -04:00
parent 646d1c9ed3
commit 0f38b89e1c
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3
4 changed files with 15 additions and 7 deletions

View file

@ -18,7 +18,7 @@ int collision(struct chunk chunk, vec3 pos, vec3 dir_temp, int col, int n) {
return 1;
}
if (yd < 0 && n == 1) {
dir_temp[1] = 0.015;
dir_temp[1] = 0.015 / 2;
pos[1] = closestVert[1];
return 1;
}
@ -80,9 +80,13 @@ struct v3f control_handler(double cx, double cy, vec3 pos, vec3 dir_temp,
}
}
vec3_add(pos, pos, dir_temp);
dir_temp[1] -= 0.03 * delta;
int is_col = 0;
if (collision(chunk, pos, dir_temp, col, 1)) {
is_col = 1;
col = 0;
off[1] = -2;
@ -106,6 +110,10 @@ struct v3f control_handler(double cx, double cy, vec3 pos, vec3 dir_temp,
struct v3f dirOut;
vec3_dup(dirOut.pos, direction);
if (is_col && fabs(dir_temp[1]) < 0.1) {
pos[1] -= dir_temp[1];
}
return dirOut;
}