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

strange results when casting ray

Discussion in 'Editor & General Support' started by Samantha, Mar 4, 2006.

  1. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    I'm using ScreenToWorldPoint to get the mouse position, then casting a ray forward. However, it doesn't look like the ray is actually moving forward, somehow it is getting moved along the Y axis...

    Any thoughts?
     

    Attached Files:

  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Not exactly positive what you're trying to achieve, but I would use Camera.ScreenPointToRay (Input.mousePosition) to cast a ray from the camera to a point in space.

    If you're just trying to cast a ray straight out from the camera FPS style then use...

    Physics.Raycast (transform.position, transform.TransformDirection (Vector3.fwd), RayHit)