using System.Collections;

using System.Collections.Generic;

using UnityEditor.PackageManager;

using UnityEngine;


public class Spin : MonoBehaviour

{

//private bool isMoving = false;

private Vector3 targetPosition = Vector3.zero;


// Update is called once per frame

void Update()

{

//if(Input.GetMouseButtonDown(0))

//{

Ray ray= Camera.main.ScreenPointToRay(Input.mousePosition);

RaycastHit hitInfo;

bool isCollider = Physics.Raycast(ray, out hitInfo);

if(isCollider&&hitInfo.collider.tag==Tags.ground)

{

//isMoving = true;

LookAtTarget(hitInfo.point);

}

//}


//if(Input.GetMouseButtonUp(0))

//{

// isMoving = false;

// }


// if(isMoving)

// {

//Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

// RaycastHit hitInfo;

//bool isCollider = Physics.Raycast(ray, out hitInfo);

//实现点击效果过

//if (isCollider && hitInfo.collider.tag == Tags.ground)

//{

// LookAtTarget(hitInfo.point);

// }

//}

}


void LookAtTarget(Vector3 hitPoint)

{

targetPosition = hitPoint;

targetPosition = new Vector3(targetPosition.x, transform.position.y, targetPosition.z);

this.transform.LookAt(targetPosition);

}

}