Skip to content

Instantly share code, notes, and snippets.

@Sammyjroberts
Created October 13, 2016 20:24
Show Gist options
  • Save Sammyjroberts/da40b509f98b09bbf8be1f6ac25d2535 to your computer and use it in GitHub Desktop.
Save Sammyjroberts/da40b509f98b09bbf8be1f6ac25d2535 to your computer and use it in GitHub Desktop.
void Update() {
if(Input.GetMouseButtonDown(0)) {
Debug.Log("ok");
Vector3 bottom = GetComponent<CapsuleCollider>().center;
Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit floorHit;
if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
{
Vector3 playerToMouse = floorHit.point - transform.position;
r.SetPosition(0, bottom);
r.SetPosition(1, floorHit.point);
Debug.Log(bottom);
Debug.Log(floorHit.point);
}
}
else {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment