Hello, I have an empty object that I want to follow my mouse cursor. The empty object has 2 cube objects as children. I have a method that sets the transform of the empty parent to the position of the mouse cursor. For some reason it’s using the childs transform so one of the cubes is the one that sticks to the cursor instead of the empty gameobject. Anyone know how I can fix this, I want the cursor to be inbetween the cubes at the parents location.
private void HandleMouseObjMovement()
{
Vector3 mousePos = Input.mousePosition;
Ray ray = Camera.main.ScreenPointToRay(mousePos);
if(Physics.Raycast(ray, out RaycastHit hitData))
{
mouseObj.transform.position = hitData.point;
}
}
In this image you cant see the cursor but its on the grey cube on the right