- Home /

# Raycasting with Rotation of Camera

I have a Line Renderer and i check if one Line of the renderer Collides with Something. I use Raycasting to check for Collision i raycast from every Vector3 of line renderer to the next one. The Problem is that the Rotation of the player isnt in my calculation, so the raycasting only takes place on one single line undependet from the players direction. I dont know how to fix that problem, here is a picture of the problem. How you can see the Rays are facing in the right direction but they are not have the right start points, it should look like in picture one, wathever direction the player is loking.

```
for (int n = 0; n < 200; n++) {
vectors[n].x = n / 10.0F;
vectors[n].y = cam.transform.position.y + 2*((vectors[n].x - 2) * (vectors[n].x - 2)) + 4;
vectors[n].z = 0;
if (n >= raycastAccuracy) {
if (Physics.Raycast(new Vector3(cam.transform.position.x, 0, cam.transform.position.z) + vectors[n - raycastAccuracy], (vectors[n - raycastAccuracy] - vectors[n] + new Vector3(cam.transform.forward.x, 0, cam.transform.forward.z)).normalized, out hit, Vector3.Distance(vectors[n - raycastAccuracy], vectors[n]))) {
if (!hit.transform.CompareTag("RemotePlayer")) {
Debug.Log(hit.transform.name);
xMax = hit.point.x;
break;
}
}
}
}
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.