- Home /
Raycast from transform.position to Player.transform.position is not raycasting to player
I did
Debug.DrawRay (transform.position, PlayerGet.transform.position);
Comment
Answer by Cherno · Mar 14, 2015 at 04:37 AM
Debug.DrawRay needs a Vector3 as the origin and a Vector3 as the direction, NOT a second "target" position. For that, you would have to use Debug.Drawline.
If you want to use Debug.DrawRay, do it like this:
Debug.DrawRay (transform.position, PlayerGet.transform.position - transform.position);
Try this
RaycastHit hit;
void Update()
{
if (Physics.Raycast (transform.position,Player.transform.position , out hit))
{
print(hit.collider.name);
Debug.DrawLine(transform.position, hit.point);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613190058im_/https://answers.unity.com/themes/thub/images/avi.jpg)