Lerp
From GECK
A function added by the JohnnyGuitar NVSE Plugin.
Description
Returns an interpolation between two inputs (v0, v1) for a parameter (t) in the closed unit interval [0, 1].
Syntax
(float) Lerp v0:float v1:float t:float
Example
set fVal to Lerp v0 v1 t
To bring the player from one point to another in a linear fashion, starting by activating a "zipline" object:
scn ZipLineScript float oldX float oldY float oldZ float newX float newY float newZ float zipX float zipY float zipZ short playerusingzipline float fCurrentTime float fTime float fTimeInSecondsHowLongShouldPlayerUseZipLine ;could be a global begin OnActivate Player if playerusingzipline == 0 set oldX to ZipLineStartREFR.GetPos X set oldY to ZipLineStartREFR.GetPos Y set oldZ to ZipLineStartREFR.GetPos Z set newX to ZipLineEndREFR.GetPos X set newY to ZipLineEndREFR.GetPos Y set newZ to ZipLineEndREFR.GetPos Z set fTimeInSecondsHowLongShouldPlayerUseZipLine to 5 set playerusingzipline to 1 set fCurrentTime to 0 DisablePlayerControls 1, 0, 0, 0, 0, 0, 0 ;prevent player from doing weird stuff. endif end begin GameMode if playerusingzipline ;* Prevent player from dying due to falling. Player.ResetFallTime Player.SetActorVelocity Z 0 ;* Displace the player. set fCurrentTime to fCurrentTime + GetSecondsPassed set fTime to fCurrentTime / fTimeInSecondsHowLongShouldPlayerUseZipLine set zipX to Lerp oldX newX fTime set zipY to Lerp oldY newY fTime set zipZ to Lerp oldZ newZ fTime player.SetPosEx zipX zipY zipZ if fTime >= 1 set playerusingzipline to 0 EnablePlayerControls endif endif end