geckosio / snapshot-interpolation

A Snapshot Interpolation library for Real-Time Multiplayer Games.
BSD 3-Clause "New" or "Revised" License
270 stars 23 forks source link

Interpolation between multiple 'deep' values. #9

Open vkbsb opened 3 years ago

vkbsb commented 3 years ago

I've seen the example where you can interpolate between just the players in the example for interpolation when the state is a nested object instead of just an array.

I have a use-case where i have to interpolate for other members of the state as well. I've been able to solve this by leveraging the snapshot.newer and snapshot.older fields to get the snapshots and interpolate between them using the percentage field provided by InterpolatedSnapshot interface.

I think it would help if the interface of InterpolatedSnapshot returned the snapshots directly instead of just the ids. This would help resolve the use-case very easily. I'm worried about the perf implications of using vault.getByID() for solving the same.

Another way of solving this would be to support multiple deep keys, but that would complicate the interpolate code.

What's your pref, i can raise a PR for changing the IDs to the actual snapshots if you are ok with it.