The spheres have a sphere collider on them and are clickable via this script:
Clickable.cs
public class Clickable : MonoBehaviour
{
void Update()
{
ClickDetect();
}
void ClickDetect()
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
Transform t = hit.collider.transform;
if (t.name == "Sphere(Clone)")
{
if (Input.GetMouseButtonDown(0))
{
hit.collider.gameObject.GetComponent<Light>().color = new Color(1, 0, 0, 0.7f);
Debug.Log(t.parent.name + (t.GetSiblingIndex() + 1));
}
}
}
}}
and the brain has a box collider on it and is moved by this script RotateonMouse
`void Rotation()
{
if (_isRotating)
{
// offset
_mouseOffset = (Input.mousePosition - _mouseReference);
// apply rotation
_rotation.y = -(_mouseOffset.x) * _sensitivity;
_rotation.x = -(_mouseOffset.y) * _sensitivity;
// rotate
transform.eulerAngles += _rotation;
// store mouse
_mouseReference = Input.mousePosition;
}
}
The issue arises when I try to click on the spheres when the box collider on the brain is on.
I end up rotating the brain instead of being able to click the spheres.
Is there a way to be able to click inside the collider while also on the collider to rotate the brain?.