Typically the way to do this is to project a ray down from the camera and hit the ground. That’s what the line Camera.main.ScreenToWorldPoint(mouse); is doing.
The position you hit is the positon your character aims towards. You could either user transform.LookAt() to have your player’s transform always looking where the mouse lands on the ground, or you could work out the direction from your character’s position to where the mouse is, calulate the angle and then rotate your character by said angle.
Your code seems to be doing that but I’m not sure what the purpose of the offset is.
Have a watch of this vid as he goes over doing this, including movment for the character.
Hey guys, if your still having the problem and seeing that the player is pointing towards your main camera, then go to your main camera and see if it’s on Orthographic and not perspective. The reason is that Orthographic is for 2d projects and perspective is for 3d games. I worked for me so well.
This is the bare minimum of information to report:
what you want
what you tried
what you expected to happen
what actually happened, log output, variable values, and especially any errors you see
links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)
The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?