WiseGravity: Gravity and Bounce

From Valve Developer Community
Jump to: navigation, search


This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

Introduction

Looking back down after the big bounce

I’ve combined two applications in this project as a result of different requests.

  1. When the player walks onto the grate it will launch them high into the air.
  2. Until they return to the first part of the map there will be low gravity.
  3. When they return to that first part gravity will be restored.

The 3 main entities in this project are:

  1. trigger_gravity (A trigger volume that changes the gravity on any entity that touches it.)
  2. trigger_push (A trigger volume that pushes entities that touch it.)
  3. func_movelinear (A brush entity that moves linearly along a given distance, in a given direction.)

If the player were to step in the lower gravity trigger area and jump they would be able to jump very high. This is not only because of the lower gravity but also from the help the player got from the trigger_push.

In this project I’ve added a func_movelinear to simulate a bounce effect like those from the original Half-Life. There are lots of ways you can create this effect and in HL1 a func_door was used.

As you noticed func_movelinear is another brush based entity. The grated area in this project is mostly func_detail, only the grating is func_movelinear. It’s so quick and smooth the player won’t notice much else about it.

Creation

Settings for the func_movelinear:

  • Name: DoorFloor
  • Move Direction: -90 0 0
  • Start Position: 0
  • Speed: 600
  • Moving Distance: 10
  • Block Damage: 0
  • StartSound: Weapon_Crossbow.BoltHitBody
  • StopSound: Bounce.Flesh

Settings for the trigger_push:

  • Start Disabled: No
  • Push Direction: -90 0 0
  • Speed of Push: 2600
  • Flags: Everything
  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnStartTouch DoorFloor Open 0.00 No
Io11.png OnStartTouch light01 TurnOn 0.00 No
Io11.png OnStartTouch DoorFloor Close 0.07 No
Io11.png OnEndTouch light01 TurnOff 0.00 No

Notice how the lights are turned on and off by the trigger_push. This really saves you a lot of work and creates oodles of possibilities.

Settings for the trigger_gravity enabling low gravity:

  • Start Disabled: No
  • Gravity: 0.1
  • Flags: Everything

The trigger for normal gravity is the same except Gravity is 1.

See also