Trouble having character face direction moving

I’ve seen a few posts about this but I’m new to scripting and having trouble figuring out how to implement some of the different solutions. I have a basic tap-to-touch function that I grabbed from here: Loading...

But when the character moves, it doesn’t change direction or orientation, regardless of where I tap. I’m trying to figure out if I need transform.LookAt or Quaternion.LookRotation, and how I would even implement it - or maybe it’s neither but I can’t figure it out regardless.

**I should clarify - it’s a 3d game with an isometric-style follow camera.

Here’s my current code - again, it’s just straight from the above link, and works great outside of the rotation issue. Thanks in advance.

public class TouchMovement : MonoBehaviour {
	private bool flag = false;
	private Vector3 endPoint;
	public float duration = 50.0f;
	private float yAxis;

	void Start(){
		yAxis = gameObject.transform.position.y;

	void Update () {

		if((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || (Input.GetMouseButtonDown(0)))
			RaycastHit hit;
			Ray ray;
			ray = Camera.main.ScreenPointToRay(Input.mousePosition);

			if(Physics.Raycast(ray,out hit))
				flag = true;
				endPoint = hit.point;
				endPoint.y = yAxis;


		if(flag && !Mathf.Approximately(gameObject.transform.position.magnitude, endPoint.magnitude)){ //&& !(V3Equal(transform.position, endPoint))){

			gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, endPoint, 1/(duration*(Vector3.Distance(gameObject.transform.position, endPoint))));
		else if(flag && Mathf.Approximately(gameObject.transform.position.magnitude, endPoint.magnitude)) {
			flag = false;


If you are tapping to move the character, that means you have a Vector3 as the “destination” or in your case “endpoint”. This will be the critical part of making the object turn towards that point.

If you are using lookat, the object you are applying lookat to will have its Z axis face the point youve plugged in. that means any rotation value as it will look directly at it. If you only want its Y axis to rotate do something like this:

player.transform.localEulerAngles = new Vector3(0,player.transform.localEulerAngles.y,0);

For Quaternion.LookRotation youll want to plug in the direction to the destination. You get that by doing something like this.

Vector3 dir = (endpoint- player.transform.position).normalized;
player.transform.rotation = Quaternion.LookRotation(dir);
//Again you will have to zero out any rotation that you do not want to happen
player.transform.localEulerAngles = new Vector3(0,player.transform.localEulerAngles.y,0);

I don’t know much about android development, but I would try to set Transform.LookAt to equal the position in which you touch. If that doesn’t work, you could always try setting up the transform.rotation to equal a particular Quaternion.Slerp when you touch.