Function
Detects when an asset is pointing at and hitting another asset, and provides information about what was hit and where.
The Vector Collision node sends a ray from an asset in a chosen direction. If it hits another asset, the node returns which asset was hit and the position of the impact. This can be used to trigger actions based on what the asset is pointing toward.
Can be connected to
- Nodes with Flow inputs (Behavior, Action, Flow Controls, Events and Triggers)
- Asset Reference Nodes
- Any node that uses collision data or triggers actions based on detection
Particularities & Node Configuration
- This Node cannot be used on its own. It must be part of a chain that includes a triggering node such as: an Event Node, a Trigger Node, an On Start Canvas, Interactive Nodes, or a Trigger Zone Node.
- The detection is based on the asset’s local direction, meaning it follows the asset’s orientation.
- The collision is detected once when triggered, not continuously.
- Rays cannot pass through assets that use the default (physics) collider.
- Rays can pass through UI assets, as they are on a different layer.
- Collisions with players are not handled and will not produce any output.
- The node is synchronized across the network and works in multiplayer.
- Using many Vector Collision nodes in large Spaces may impact performance.
The Vector Collision node contains the following fields:
- Asset
Defines the source asset from which the detection is performed. - Direction
Defines the direction in which the detection is performed.
The node provides the following outputs:
- Hit Object
Outputs the asset that was hit. - Collision Position
Outputs the position where the collision occurred.
Using the Vector Collision Node
Example: Detect an object over another
In order to recreate this scenario, you’ll need to place these assets in your Space:
- A Canvas
- A button
- A cube
- A cone
When the button is pressed, an invisible ray is emitted in the upward direction of the cone, coming out of its top in this example, and hitting the cube placed in its path. The cube then glows when the raycast collides with it.
Result :