Raycaster firing backwards [Solved]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Andersonreis42
Prole
Posts: 1
Joined: Thu Jan 25, 2024 6:25 pm

Raycaster firing backwards [Solved]

Post by Andersonreis42 »

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:
ok ray.png
ok ray.png (7.01 KiB) Viewed 3113 times
ray not ok.PNG
ray not ok.PNG (9.34 KiB) Viewed 3113 times
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.
Attachments
main.lua
(3.29 KiB) Downloaded 101 times
Last edited by Andersonreis42 on Fri Jan 26, 2024 12:30 pm, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 69 guests