- Home /

# Raycasting with Rotation of Camera

I have a Line Renderer and i check if one Line of the renderer Collides with Somet$$anonymous$$ng. 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 $$anonymous$$t, Vector3.Distance(vectors[n - raycastAccuracy], vectors[n]))) {
if (!$$anonymous$$t.transform.CompareTag("RemotePlayer")) {
Debug.Log($$anonymous$$t.transform.name);
xMax = $$anonymous$$t.point.x;
break;
}
}
}
}
```

### Your answer

### Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

### Follow this Question

### Related Questions

Problem with raycasting, checking for ground doesn't work 3 Answers

Raycast causes all enemies to attack 1 Answer

Release camera 1 Answer

Raycasting Help 1 Answer

Mouse pos + raycast 1 Answer