I have a question about setting custom objects as IRaycastables. In my game I have floating cube objects and a script called “QuestTarget” which I created. QuestTarget implements IRaycastable.
Floating Cube: It is 6 quad faces oriented to line up with the faces of a cube. I did quads instead of a cube because I want to individually texture each face of it (or at least 4 of the 6 that I care about). Here’s where I run into some issues.
The parent object floating cube is an IRaycastable because it has the QuestTarget script on it but the objects that get hit with the Raycast are the children and they are just plain quads.
For IRaycastable to work it seems I need to put QuestTarget on each face (it would require some changes to my script but doable).
But putting a QuestTarget script onto each face seems like a hack. Is there a smarter way to do this?
public class QuestTarget : MonoBehaviour, IRaycastable {
public CursorType GetCursorType()
{
return CursorType.ClaimQuestItem;
}
public bool HandleRaycast(PlayerController callingController)
{
if (Input.GetMouseButtonDown(0))
{
ClaimQuestItem();
}
return true;
}
}