class HitInfo(val entity: Entity?, val sceneObjectHandle: Long, val nodeId: Int, val meshElementId: Int, val distance: Float, val point: Vector3, val normal: Vector3, val textureCoordinate: Vector2)
// Perform a ray cast from the controller position in the forward direction
val hitInfo = scene.lineSegmentIntersect(
dataModel,
controllerPosition,
controllerPosition + (controllerForward * maxDistance)
)
// Check if something was hit
if (hitInfo != null) {
// Access hit information
val hitEntity = hitInfo.entity
val hitPoint = hitInfo.point
val hitNormal = hitInfo.normal
val hitDistance = hitInfo.distance
// Perform actions based on the hit
if (hitEntity != null) {
// Interact with the hit entity
}
}
| Name | Summary |
|---|---|
HitInfo |
| Name | Summary |
|---|---|
distance | val distance: Float The distance from the ray origin to the hit point |
entity | |
meshElementId | val meshElementId: Int The ID of the mesh element (e.g., triangle) that was hit |
nodeId | val nodeId: Int The ID of the node in the SceneObject that was hit |
normal | |
point | |
sceneObjectHandle | val sceneObjectHandle: Long The handle of the SceneObject that was hit |
textureCoordinate |