Skip to content

Instantly share code, notes, and snippets.

@Sammyjroberts
Created October 14, 2016 15:25
Show Gist options
  • Save Sammyjroberts/ae2aac0baff9758e0c0432cd35179bb6 to your computer and use it in GitHub Desktop.
Save Sammyjroberts/ae2aac0baff9758e0c0432cd35179bb6 to your computer and use it in GitHub Desktop.
void Update() {
if(Input.GetMouseButton(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;
Vector3 bottom = transform.position;
bottom.y=0.1f;
Vector3 floorHitfix = floorHit.point;
floorHitfix.y = 0.1f;
r.SetPosition(0, bottom);
r.SetPosition(1, floorHitfix);
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