Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Raycast from local position

Discussion in 'Physics' started by Whiskas009, Nov 19, 2022.

  1. Whiskas009

    Whiskas009

    Joined:
    Aug 21, 2022
    Posts:
    28
    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.
    Line.gif

    Here is my current code:
    upload_2022-11-19_21-45-8.png
     
  2. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    660
    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.
     
    Whiskas009 likes this.
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,541
    Just replace "Vector3.forward" with "transform.forward" in your code.
     
    Whiskas009 likes this.
  4. Whiskas009

    Whiskas009

    Joined:
    Aug 21, 2022
    Posts:
    28
    Thx)
     
  5. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,508