Hello!I’m having a little trouble with rays currently.Let say i have and object in 2D scene(Player) and i want my 2d ray to cast from obejcts(Players) position to my mouse position and whatever code i use the ray will start at the objects pos but its end wont be on my mouse position,the ray goes somewhere else and i dont know why.Here’s a bit of my code:
Vector3 mousePos = Input.mousePosition;
mousePos.z = dist; //changing this value will change the ray casting somehow but still its not working right
Vector3 screenPos = Camera.main.ScreenToWorldPoint(mousePos);
Debug.DrawRay(transform.position,screenPos,Color.green);