mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
better water
This commit is contained in:
parent
4a8973aeac
commit
38353751c9
11 changed files with 167 additions and 16 deletions
|
@ -101,11 +101,28 @@ void Environment::step(float dtime)
|
|||
{
|
||||
Player *player = *i;
|
||||
|
||||
// Apply gravity to local player
|
||||
// Apply physics to local player
|
||||
if(player->isLocal())
|
||||
{
|
||||
// Apply gravity to local player
|
||||
v3f speed = player->getSpeed();
|
||||
speed.Y -= 9.81 * BS * dtime_part * 2;
|
||||
|
||||
/*
|
||||
Apply water resistance
|
||||
*/
|
||||
if(player->in_water)
|
||||
{
|
||||
f32 max_down = 1.0*BS;
|
||||
if(speed.Y < -max_down) speed.Y = -max_down;
|
||||
|
||||
f32 max = 2.0*BS;
|
||||
if(speed.getLength() > max)
|
||||
{
|
||||
speed = speed / speed.getLength() * max;
|
||||
}
|
||||
}
|
||||
|
||||
player->setSpeed(speed);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue