aboutsummaryrefslogtreecommitdiffstats
path: root/code/pawn/component/movement
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2023-07-29 02:55:08 +0100
committerLeonardo Bishop <me@leonardobishop.com>2023-07-29 02:55:08 +0100
commit95b2259eb4d7362b137d26037f8312b3d80f0244 (patch)
tree430f4b61bba71e93802d0edaf61f97a162627666 /code/pawn/component/movement
parent743c93752eccb4d243c5869ec82dceb1c443acac (diff)
Add fall damage
Diffstat (limited to 'code/pawn/component/movement')
-rw-r--r--code/pawn/component/movement/PlayerController.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/code/pawn/component/movement/PlayerController.cs b/code/pawn/component/movement/PlayerController.cs
index 885bf84..2c9a9b9 100644
--- a/code/pawn/component/movement/PlayerController.cs
+++ b/code/pawn/component/movement/PlayerController.cs
@@ -36,8 +36,18 @@ public class PlayerController : EntityComponent<Player>
{
if ( !Grounded )
{
- Entity.Velocity = Entity.Velocity.WithZ( 0 );
+ var zVel = Entity.Velocity.z;
AddEvent( "grounded" );
+ Entity.Velocity = Entity.Velocity.WithZ( 0 );
+
+ if (zVel < -500)
+ {
+ var damageInfo = DamageInfo.Generic( Math.Abs((float)(zVel * 0.05)) );
+ Entity.TakeDamage( damageInfo );
+ Entity.PlaySound( "fall" );
+ return;
+ }
+
}
var sprintMultiplier = TeamOperations.CanSprint( team ) ? (Input.Down( "run" ) ? 2.5f : 1f) : 1f;