beta
cables is under heavy development.
There might be one or another bug, please let us know about it!

CannonCastRay Op

Ops.Physics.Cannon.CannonCastRay


CannonCastRay

cast a ray and test intersection with physics bodies


summary (oneliner)

Cast Ray allows you to pick 3d objects that are defined in your physics world (Ops.Physics.World).

One use case may be a 3D menu, where your buttons are cube meshes with physics cubes (Ops.Physics.Body.PhysicsCube_v2) placed in the same exact location.
With Cast Ray placed in your physics world, you will be able to test when a mouse cursor intersects with one of the cubes, allowing you to use the cube as a button.

When using a Mouse OP with CastRay to pick your physics objects, make sure to directly plug in your Mouse op X/Y into the CastRay op and turn on Normalize in the Mouse OP.



doc

issues

example patch id

youtube id

caniuse query

collections

related ops

Inputs

Exec (Trigger)

Trigger in


Screen X (Number)

Position of the ray on the X axis 0.0 is the center of the screen


Screen Y (Number)

Position of the ray on the Y axis 0.0 is the center of the screen


Screen Z (Number)

Position of the ray on the Z axis 0.0 is the center of the screen


Change Cursor (boolean /Number)

Outputs

Next (Trigger)

Trigger out


Has Hit (Number)

if the ray intersects/hits a physics body then 1 is output


Hit X (Number)

Intersection position in world space on the X axis


Hit Y (Number)

Intersection position in world space on the Y axis


Hit Z (Number)

Intersection position in world space on the Z axis


Hit Normal X (Number)

which normal was picked on the object on X axis (-1,0,1)


Hit Normal Y (Number)

which normal was picked on the object on Y axis (-1,0,1)


Hit Normal Z (Number)

which normal was picked on the object on Z axis (-1,0,1)


Result (Object)

object containing all parameter information and some extras, inspect to see which ones are available to parse out


aabb x (Number)

aabb y (Number)

aabb z (Number)

aabb x2 (Number)

aabb y2 (Number)

aabb z2 (Number)

to x (Number)

to y (Number)

to z (Number)

from x (Number)

from y (Number)

from z (Number)

Body x (Number)

location of picked physics body on X axis


Body y (Number)

location of picked physics body on Y axis


Body z (Number)

location of picked physics body on Z axis


Name (String)

name and number of picked object - Name is set in a physics body operator and the number is assigned after it with a ".#" format


Caught a mistake or want to contribute to the documentation?

Edit Documentationcancel save

CastRay example interactive

Open Example In Editor


Youtube Video Tutorial

Patches using CannonCastRay

Changelog


created op
2019-02-12 - pandur

Ops.Exp.Gl.Physics.CastRay renamed to Ops.Physics.CastRay
2020-07-30 - pandur

Ops.Physics.CastRay renamed to Ops.Physics.Cannon.CannonCastRay
2022-06-07 - pandur