I’m trying to implement free flow combat (think arkham asylum), and one of the core building blocks of the system is adding movement to the attack- once I determine who the player is targeting, if that enemy is in range, I want to interpolate the player’s transform from their current position to the enemy’s position over a fixed duration, say 0.5s, then ensure that every attack starts with 0.5s of windup that will hide/dress up the movement.
The most obvious way to do this seems to be something like
void Update(){
if (bInterpToEnemy){
playerObject.position = Vector3.Lerp(start.position, end.position, ((Time.time - startTime)*speed)/length);
}
}
The problem is, you’re only going to want to interpolate while attacking, which will be less than 20% of the game’s total runtime, so 80% of the time I’ll be making a useless check every frame - is there any way I can get this in a self-contained function, given the fact that location interpolation needs to be execute over multiple frames to look natural?