2
Hello, I’m doing a 3-D game and I’m having trouble doing a 3-D raycasting. In this case, I want to do it for the camera, to see if there is no object between the camera and the player. For this I need to find a vertex that represents the angle and check on the map whether there are obstacles or not. The camera guards the angle of two axes: Y axis (modified with the mouse movement in the horizontal, X axis of the screen in the 2D plane) and X axis (modified with the mouse movement in the vertical, Y axis of the screen in the 2D plane). I can make raycast from any of these angles by myself, but I can’t put them together to make raycast in 3 dimensions. The problem is that they both share the Z (the sine of the Y-axis and the cosine of the X-axis). If I multiply the two between each other, the result is only correct when the angle Y is 0º or 90º. If not, it is reversed.
What formula should I use to calculate the Z-value?
Complex, I think you’ll have to post this question on Math since it does not imply code, only formula.
– KaduAmaral