Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I know it sounds silly but I'm not comfortable posting the art for the game yet, i know its irrelevant for game jams but i just prefer it that way.

So i mocked up a 2D image of my problem instead. Although my game is 3D, it's orthographic and fixed camera angle. The way my movement is set up is you can click any adjacent tiles to the player and the player will move to that tile using

transform.position = Vector3.Lerp(transform.position, destinationTile.position + new Vector3(0,1,0), 3f * Time.deltaTime);

That works fine, my problem is i can't seem to figure out how to get the character to rotate when turning a corner, eg always facing in the direction of movement. Iv'e tried a few different bits of code iv'e found online, so far the below code is closest to working, although it appears i need to somehow add an offset to X and Y by 90 degrees because the character rotates but appears to be on a different angle.

Vector3 targetRot = destinationTile.position - transform.position;
Vector3 newRot = Vector3.RotateTowards(transform.forward, targetRot, 1 * Time.deltaTime,0.0f);
transform.rotation = Quaternion.LookRotation(newRot);

Appreciate the help and hope this sort of thing is ok for this group.