Jump to content

Linear Interpolation


Recommended Posts

Unreal has Interp and Unity has Lerp, here is Linear Interpolation on Oblivion.

 

The core functions uses the start and destination coordinates of the object - these do not change.

 

EDIT: the following line should be "Your code has to tell them how Fast the object should go from start (0) to destination (1).
Your code has to tell them how far the object is from start (0) to destination (1).
'FnNormalizedIncrement Seconds' returns the increment to achieve this.
The increment is capped at 30fps to ensure almost any computer can smoothly render it - if not, just run a little slower.

NOTE:
The timing on GetSecondsPassed is at 30fps to sync with fIncrement.
GameMode could be re-factored but without code reduction - I think this is okay.

The problem I have is explaining this simply and making it easy to use. This is simply an A-B demonstration where multiple destinations and/or looping is a little harder.

My question is whether anyone is going to bother to use it?
Is it worth me taking time to develop the tutorials?

scn kvLerpObjectScript

int iActivated
array_var arrPositionStart
array_var arrPositionEnd
array_var arrRotationStart
array_var arrRotationEnd
array_var arrCurrentPosition
array_var arrCurrentRotation
float fIncrement
float fInterval
float fTimer

Begin OnActivate

	if iActivated == 0
		
		let iActivated := 1
		
		let arrPositionStart := call FnGetVector3Position kvLerpObjectRef
		let arrPositionEnd := call FnGetVector3Position kvMkrLerpObject

		let arrRotationStart := call FnGetVector3Rotation kvLerpObjectRef
		let arrRotationEnd := call FnGetVector3Rotation kvMkrLerpObject

		let fInterval := 0
		let fIncrement := call FnNormalizedIncrement 20
		
	endif
	
End

Begin GameMode
	
	if iActivated == 1
		
		let fTimer += GetSecondsPassed
		
		if fTimer >= (1 / 30)
		        
                        let fTimer := 0

			let arrCurrentPosition := call FnLerpPosition arrPositionStart, arrPositionEnd, fInterval
			call FnSetPosition kvLerpObjectRef, arrCurrentPosition[0], arrCurrentPosition[1], arrCurrentPosition[2]
			
			let arrCurrentRotation := call FnLerpRotation arrRotationStart, arrRotationEnd, fInterval
			call FnSetRotation kvLerpObjectRef, arrCurrentRotation[0], arrCurrentRotation[1], arrCurrentRotation[2]
			
			let fInterval += fIncrement
			
			if fInterval >= 1
				let iActivated := -1
			endif
			
		endif
		
	endif
	
End
  • Like 1
Link to comment
Share on other sites

This uses Linear Interpolation.

 

Fire == Drop/Grab where Grab is up to 30 virtual meters.

Fire+Sprint == Throw at up to 15 virtual meters

Fire+Alt-Fire == Hurl at up to 30 virtual meters.

 

 

Fire is also Use - whatever you're looking at, saving whatever other inputs certain games waste our fingers on.

 

Unity Cross-Platform (UCPI) Input hard codes Left and Right Mouse - the only reason I can play this is because I deleted UCPI on my game. I have acute ulna compression and nerve damage in my left shoulder.

After deleting UCPI, it took me a few days to write an interface to bind anything to anything on any platform using keyboard, mouse and/or controller (all at the same time) - it is working here, wtf is wrong with these high paid AAA game programmers that don't do this?!

 

Note that the color coded buttons seem to be magnetic in response to matching colored cubes - the reason for the shape of the halls. When we grab a cube off a button it's collision physics stop. The idea is to bounce the cube you're holding off the cornice then grab the cube on the button fast enough so it all works - I stuffed this up a lot nearly failing time on this level.

 

Similar can be done on Oblivion but it needs to be an out of process plugin. I'm not seeing a way to extend OBSE or write it independently.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...