mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
restore player 0.28 controls
This commit is contained in:
parent
dde8c674b8
commit
5f2c0f69ce
3 changed files with 11 additions and 8 deletions
|
|
@ -20,7 +20,7 @@ end
|
||||||
def_prop("jump_force", 0.0)
|
def_prop("jump_force", 0.0)
|
||||||
def_prop("air_damping", 10.0)
|
def_prop("air_damping", 10.0)
|
||||||
def_prop("ground_damping", 10.0)
|
def_prop("ground_damping", 10.0)
|
||||||
def_prop("movement_speed", 3.0)
|
def_prop("movement_speed", 27.0)
|
||||||
def_prop("run_speed_mul", 1.5)
|
def_prop("run_speed_mul", 1.5)
|
||||||
def_prop("crouch_speed_mul", 0.35)
|
def_prop("crouch_speed_mul", 0.35)
|
||||||
def_prop("flight_speed_mul", 2.0)
|
def_prop("flight_speed_mul", 2.0)
|
||||||
|
|
@ -62,9 +62,8 @@ local function move_horizontal(speed, dir, vel)
|
||||||
vec2.normalize(dir, dir)
|
vec2.normalize(dir, dir)
|
||||||
|
|
||||||
local delta = time.delta()
|
local delta = time.delta()
|
||||||
local damping = body:get_linear_damping()
|
vel[1] = vel[1] + dir[1] * speed * delta
|
||||||
vel[1] = vel[1] + dir[1] * speed * delta * damping
|
vel[3] = vel[3] + dir[2] * speed * delta
|
||||||
vel[3] = vel[3] + dir[2] * speed * delta * damping
|
|
||||||
end
|
end
|
||||||
body:set_vel(vel)
|
body:set_vel(vel)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ local function process_player_inputs(pid, rot, delta)
|
||||||
|
|
||||||
if mob.is_flight() then
|
if mob.is_flight() then
|
||||||
if isjump then
|
if isjump then
|
||||||
mob.move_vertical(speed * 3)
|
mob.move_vertical(speed / 4.0)
|
||||||
elseif iscrouch then
|
elseif iscrouch then
|
||||||
mob.move_vertical(-speed * 3)
|
mob.move_vertical(-speed / 4.0)
|
||||||
end
|
end
|
||||||
elseif body:is_grounded() and isjump then
|
elseif body:is_grounded() and isjump then
|
||||||
mob.jump()
|
mob.jump()
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,6 @@ bool PhysicsSolver::calcCollisionNegY(
|
||||||
if (vel.y >= 0.0f) {
|
if (vel.y >= 0.0f) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hitbox.groundVelocity = {};
|
|
||||||
for (int ix = 0; ix <= glm::ceil((half.x - E) * 2); ix++) {
|
for (int ix = 0; ix <= glm::ceil((half.x - E) * 2); ix++) {
|
||||||
glm::vec3 coord;
|
glm::vec3 coord;
|
||||||
coord.x = (pos.x - half.x + E) + ix;
|
coord.x = (pos.x - half.x + E) + ix;
|
||||||
|
|
@ -202,6 +201,7 @@ bool PhysicsSolver::calcCollisionNegY(
|
||||||
vel.y = -hitbox.elasticity * vel.y;
|
vel.y = -hitbox.elasticity * vel.y;
|
||||||
pos.y = newy;
|
pos.y = newy;
|
||||||
}
|
}
|
||||||
|
hitbox.groundVelocity = {};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -398,6 +398,10 @@ void PhysicsSolver::step(
|
||||||
for (auto hitbox : hitboxes) {
|
for (auto hitbox : hitboxes) {
|
||||||
float linearDamping = hitbox->linearDamping;
|
float linearDamping = hitbox->linearDamping;
|
||||||
|
|
||||||
|
if (hitbox->grounded) {
|
||||||
|
linearDamping = 10.0f; // TODO: add friction to material
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3& vel = hitbox->velocity;
|
glm::vec3& vel = hitbox->velocity;
|
||||||
auto diff = hitbox->groundVelocity - vel;
|
auto diff = hitbox->groundVelocity - vel;
|
||||||
vel.x += diff.x * delta * linearDamping;
|
vel.x += diff.x * delta * linearDamping;
|
||||||
|
|
@ -407,7 +411,7 @@ void PhysicsSolver::step(
|
||||||
vel.y /= 1.0f + delta * linearDamping * hitbox->verticalDamping;
|
vel.y /= 1.0f + delta * linearDamping * hitbox->verticalDamping;
|
||||||
}
|
}
|
||||||
if (!hitbox->grounded) {
|
if (!hitbox->grounded) {
|
||||||
hitbox->groundVelocity = {};
|
hitbox->groundVelocity *= 1.0f - delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSensors(*hitbox);
|
updateSensors(*hitbox);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue