Pushing a player around - pushplayer.nut

/*--------------------------------------------
author: https://leeland.info
file:pushplayer.nut
description: 
Allows you to add a velocity vector to any player via trigger. 
Call it from a trigger with something like
OnStartTouch !activator runscriptcode OurPushPlayer(0,0,400)
OnStartTouch !activator runscriptcode OurPushPlayer(-200,100,400)
etc

A note on values, 4096 is the maximum velocity, values below 250 don't move the player at all. 
Z Values around 700 will incap, 1000 or so will prove fatal




--------------------------------------------*/

function OurPushPlayer(x,y,z) {
   local addv = Vector(x,y,z); // 4096 max velocity, anything higher is clamped
   local v = self.GetVelocity()
   self.SetVelocity(v+addv);
}


// slip in a reference to our function in the global table so we can access from all objects,
// *technique to use sparingly! Your function could overwrite another. Name uniquely to try and avoid conflicts*
::OurPushPlayer <- OurPushPlayer;
Scroll to top