Problem with infinite rays and position of raycast

  1. You are generating a ray per frame in your castRay() function. This function creates an helper which in turn generate a mesh (per frame again). So no wonder why it is slow :slight_smile: Why are you generating a ray per frame? (scene.registerBeforeRender is called once a frame)

  2. You can create a dummy box, attach your box to the bone with mesh.attachToBone and then attach your ray to this dummy box

2 Likes