Ray ray = new Ray(RayOrigin.transform.position, RayOrigin.transform.forward);
RaycastHit hit = new RaycastHit();
if (Input.GetMouseButtonDown(0) && Physics.Raycast (ray, out hit, 20f) && hit.collider.gameObject.CompareTag("Pickable"))
{
currRBcons = hit.rigidbody;
currRBcons.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
if (Input.GetMouseButtonUp(0))
{
currRBcons.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None;
currRBcons = null;
}
I need my hit to be a bit wider and more generous in the radius. Thus I need a spherecast. Is it possible to convert this into a spherecast, if so how? I found Unity’s api to be lacking on the topic.