From 9ffbd5ff006e82230afa077d8c58e59f0966127c Mon Sep 17 00:00:00 2001 From: vinci6k Date: Tue, 16 Mar 2021 20:28:46 +0100 Subject: [PATCH] Added the bouncy_water.py example. --- examples/bouncy_water/bouncy_water.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/bouncy_water/bouncy_water.py diff --git a/examples/bouncy_water/bouncy_water.py b/examples/bouncy_water/bouncy_water.py new file mode 100644 index 0000000..9047de6 --- /dev/null +++ b/examples/bouncy_water/bouncy_water.py @@ -0,0 +1,15 @@ +# ../bouncy_water/bouncy_water.py + +# Enki +from enki.listeners import OnPlayerEnterWater + + +@OnPlayerEnterWater +def on_player_enter_water(player): + """Called when the player starts touching water.""" + # Get the direction the player is moving in. + direction = player.velocity.normalized() + # Exaggerate the Z axis - this will make the player go up. + direction.z = 0.9 + # Push the player away from the water surface. + player.teleport(velocity=direction * 450)