Too subjective and argumentative
Raycast hits Ray origin, possibly, randomly.
Hello,
Long-time reader, first time questioner.
Using Unity's tutorial for FPS (https://unity3d.com/learn/tutorials/lets-try/shooting-with-raycasts?playlist=41639) I have been trying to create a shooting game.
Unfortunately, the ray occasionally shoots at the camera origin instead of forward. Basically shooting the player in the face.
I have copy and pasted the script from the tutorial as it is presented and still have the problem. Is there a setting I'm getting wrong, or an issue I'm not aware of?
It appears most problematic while moving.
Thank you!
Answer by ZachJohnson · Apr 07, 2018 at 05:05 PM
My solution was to set the player on the layer which ignores raycasting. Now my rays never shoot myself!
Answer by ZachJohnson · Apr 04, 2018 at 01:57 AM
Updating the information here in hopes that it inspires some insight into my problem:
The Ray cast--mostly when I'm aimed downward at about a 45 degree angle--is targeting my Camera.
I used a different tutorial with a simpler script (https://www.youtube.com/watch?v=THnivyG0Mvo) and ran into the same issue. The raycast targets the camera. I confirmed this by doing a debug.log on the hit.point--I then checked the coordinates against the camera's location at the time the raycast was activated.
Why would the Raycast go backwards toward my camera from which it is meant to originate?
Follow this Question
Related Questions
RayCast2D and RayDraw errors 0 Answers
How would I project a Gameobject onto the surface of another? 0 Answers
raycasting doesn't work 1 Answer