Hey all,
I'm seeking a better solution to raycasting from the players view to check if they are looking at a block. The entity's builtin one is inaccurate.
Please see code and image below.
system.afterEvents.scriptEventReceive.subscribe(e => {
// Get source entity and location
let srcEntity = e.sourceEntity;
// Send raycast
let blockRaycastHit = srcEntity.getBlockFromViewDirection()
if (typeof blockRaycastHit !== "undefined") {
if (typeof blockRaycastHit.block !== "undefined") {
let block = blockRaycastHit.block
world.sendMessage(block.typeId) // Say block name
...
}
}
}
})