Raycast from local position

Hello everyone Please tell me how to release the beam in the local direction? Then in the direction where the Z axis is directed (blue).
I think it still needs to be drawn correctly.
8599155--1153461--Line.gif

Here is my current code:
8599155--1153464--upload_2022-11-19_21-45-8.png

You need to supply it the proper direction. Vector3 as used there is always pointing North. Try using the transform.forward of the transform that you are clearly moving in that vid.

1 Like

Just replace “Vector3.forward” with “transform.forward” in your code.

1 Like

Thx)

A possibly useful post I made some years ago: