You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**📔 Note**: You can get a raycast result from hitting an entity on a different scene. This may be especially useful when creating portable experiences or smart wearables, that can react to the surroundings.
198
-
199
-
However, note that currently you can only obtain raycast responses when the collision is with conent in a scene done with SDK7. Older SDK6 scenes won't return any hit result.
197
+
**📔 Note**: You can get a raycast result from hitting an entity on a different scene.
200
198
{{< /hint >}}
201
199
200
+
## Handle hit entities
201
+
202
+
When you get a raycast result that hit an entity, you can use the `entityId` to interact with the entity and its components. An entity is [nothing more than a number]({{< ref "/content/creator/sdk7/architecture/entities-components.md#overview" >}}), so the `entityId` value itself can be interpreted as an `Entity` type.
**📔 Note**: Keep in mind that in 3rd person the cursor could in the future not behave the same as in 1st person. It's recommended to only use this if the player is in 1st person.
385
392
{{< /hint >}}
386
393
394
+
## Raycast from the cursor position
395
+
396
+
You can also trace a ray from the player's cursor position into the 3D world. This can be used to drag objects around, shooters, etc.
Copy file name to clipboardExpand all lines: content/creator/sdk7/interactivity/user-data.md
+49-4Lines changed: 49 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -435,17 +435,62 @@ The `primaryPointerInfo` component returns an object with the following properti
435
435
-`pointerType`: 0 for `none`, 1 for `mouse`
436
436
437
437
438
-
You can use the `worldRayDirection` to set the `direction` field of a raycast to know if an entity is in the cursor's line of sight. See [Raycasting]({{< ref "/content/creator/sdk7/interactivity/raycasting.md" >}}) for more details.
439
-
440
-
441
438
{{< hint info >}}
442
439
**💡 Tip**: To react to simple hover events on UI elements, you may find it easier to use the `onMouseEnter` and `onMouseLeave` events, see [UI Button Events]({{< ref "/content/creator/sdk7/2d-ui/ui_button_events.md#hover-feedback" >}}).
443
440
{{< /hint >}}
444
441
445
442
443
+
The `primaryPointerInfo` component is read-only, you can't force the player to change the cursor position.
446
444
447
445
448
-
The `primaryPointerInfo` component is read-only, you can't force the player to change the cursor position.
446
+
The following example shows how to display the cursor position on a UI element.
You can use the `worldRayDirection` to set the `direction` field of a raycast to know if an entity is in the cursor's line of sight. See [Raycasting]({{< ref "/content/creator/sdk7/interactivity/raycasting.md" >}}) for more details.
0 commit comments