We are developing a 3D RPG game for iOS, but movement is restricted to a tile based view similar to many retro titles such as Dungeon Master.
I've been moving the player using physics, but I've just re-worked the collision system so that we don't need to rely on the collision model and instead we have a pre-baked map of whether a tile can be entered and how one can move from tile to tile, so I am wondering if it is cheaper to move the player by animating them from tile position to tile position, given that I already know these positions and whether the tile is free or not.
So I can do this by creating an AnimationCurve via AnimationCurve.Linear but I presume this is creating a new curve, but I wonder if it's coming from a pool of curves and whether by using this I will (or won't) increase garbage collection. Were I on pro I'd profile it to see, but I am not sadly :-(
I was hoping to create one animation clip, squirrel the curves and keys away and update them but this doesn't seem to work and results in a lot of method calls compared to the code below:
I've not dabbled in this area before, so I'm open to more efficient ways. I wasn't sure what title to go with, partly I'd like to know about the garbage collection on the phone, partly the cheapest solution.
Motivation for this is that I wanted to push the heavy lifting into the native code instead of doing this in Update() or within a Coroutine. Naturally removing the physics dependency ought to be quicker.