Trying to make a raycaster

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
User avatar
steVeRoll
Party member
Posts: 131
Joined: Sun Feb 14, 2016 1:13 pm

Trying to make a raycaster

Post by steVeRoll »

I decided to make a raycaster, but it doesn't look like any other raycaster there is. And I kind of expected it to be like that, I don't know how other raycasters do it.
So how does mine work? It sends out rays from the player's position, and then it checks each one. If a ray hit something, it's gonna draw a rectangle with a height depending on the length of said ray.
Usually in 3d games (raycasting or not), when you stand in front of a straight wall, it's gonna look straight, right? Well, in my case, it's not. Because rays are sent out around the player - the closer a ray is to the center of the screen, the more curved the wall is going to appear.
Screenshot_1.png
Screenshot_1.png (27.13 KiB) Viewed 3698 times
Looks weird, right?
How do other raycasters work? And how can I fix mine? Thanks in advance!
Attachments
raycaster(kindof).love
(1.26 KiB) Downloaded 143 times
Skeletonxf
Citizen
Posts: 87
Joined: Tue Dec 30, 2014 6:07 pm

Re: Trying to make a raycaster

Post by Skeletonxf »

I think you need to somehow get all the rays from the player to the corners of each rectangle shape and fill in the spaces in between so the sides look straight and the edges well defined.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Trying to make a raycaster

Post by Jasoco »

No, you need to adjust for the fisheye effect. I don't know exactly how you do that but when I made my first raycaster, someone helped me with it too. I'd suggest searching the forums for one of the many raycaster projects people have made. I suggest either mine or Davidobot's.

I'll save you the trouble.

Here's David's thread: viewtopic.php?f=5&t=78608&hilit=raycast
Here's mine: viewtopic.php?f=4&t=6834&p=45728&hilit=raycast
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Trying to make a raycaster

Post by Positive07 »

Found this here:
Image
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Sarius
Prole
Posts: 2
Joined: Tue Jan 08, 2019 7:02 pm

Re: Trying to make a raycaster

Post by Sarius »

There should be more tutorials for doing this in Lua, cause i can't find any as of right now ;(
Post Reply

Who is online

Users browsing this forum: No registered users and 68 guests