From 38353751c9f4e03fb6a0b855e6d8b5691af71dc0 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 30 Nov 2010 15:35:03 +0200 Subject: better water --- src/environment.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/environment.cpp') diff --git a/src/environment.cpp b/src/environment.cpp index c76721a77..2d7590f1a 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -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); } -- cgit v1.2.3