Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Raycast hit convert code in Raycast2D

Discussion in '2D' started by roshan090, Jun 18, 2019.

  1. roshan090

    roshan090

    Joined:
    Mar 20, 2018
    Posts:
    30
    i am not very good in raycast. can someone please help me to convert these line of code in 2D

    RaycastHit hit;
    if (Physics.Raycast(transform.position, direction, out hit, 100f))
    {
    nextCollisionPosition = hit.point;
    Debug.Log(hit.collider.name);
    }
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    1,375
    Why not just use Physics2D.Raycast and RaycastHit2D?

    Edit:
    Also, please do not spam threads. You don't need to ask the same question in multiple subforums.
     
unityunity