I'm coming back to try and wrap up this discussion.
Does the "objectTag" option set in the RayCastGizmo interface get used in the script?
ANSWER: no, it's not taken into account.
Gausroth actually pointed me in the right direction from the start. I just didn’t understand how to access hit.target (my IDE didn’t show it — I just needed to cast hit properly to EntityRaycastHit).
Here's a small function that might help clarify things and be useful to others.
export function rayCastObjectByTag(rayCaster: hz.RaycastGizmo, direction: hz.Vec3, tag: string, maxDist = 10): hz.RaycastHit | null {
const pOrigin = rayCaster.position.get();
const options = { layerType: hz.LayerType.Both, maxDistance: maxDist };
const hit = rayCaster.raycast(pOrigin, direction, options);
if (hit && hit.targetType === hz.RaycastTargetType.Entity) {
const entity = hit.target;
if (entity.tags.contains(tag)) return hit;
}
return null;
}
Thanks a lot for your patience 😉