Raycaster firing backwards [Solved]
Posted: Thu Jan 25, 2024 6:45 pm
Hey!
I'm following 3DSage's tutorial and I could solve some issues with the code just fine, and i've managed to make it work. However, sometimes the ray is fired backwards: the yellow dash is the player's direction. I think the issue might be caused by the snippets and conditionals regarding to wheter the ray is facing left-right-up-down with given angle since it always happens at the same angle range, but I can't pinpoint the cause!
About the code, i'm casting both horizontal and vertical checks separately because i'm using windows defeault notepad and it tends to get a bit messy...
Thanks in advance for your input!
-EDIT-
Hey guys! I've managed it out.
In function raycastV() the line rx = math.floor((py / 64)) * 64 - 1 should be rx = math.floor((px / 64)) * 64 - 1. I just wrote it wrong!
I'm uploading the correct code incase someone is interested in casting rays.
I'm following 3DSage's tutorial and I could solve some issues with the code just fine, and i've managed to make it work. However, sometimes the ray is fired backwards: the yellow dash is the player's direction. I think the issue might be caused by the snippets and conditionals regarding to wheter the ray is facing left-right-up-down with given angle since it always happens at the same angle range, but I can't pinpoint the cause!
About the code, i'm casting both horizontal and vertical checks separately because i'm using windows defeault notepad and it tends to get a bit messy...
Thanks in advance for your input!
-EDIT-
Hey guys! I've managed it out.
In function raycastV() the line rx = math.floor((py / 64)) * 64 - 1 should be rx = math.floor((px / 64)) * 64 - 1. I just wrote it wrong!
I'm uploading the correct code incase someone is interested in casting rays.