Page 1 of 1

Trying to make a raycaster

Posted: Sun Jul 31, 2016 9:36 am
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 3859 times
Looks weird, right?
How do other raycasters work? And how can I fix mine? Thanks in advance!

Re: Trying to make a raycaster

Posted: Sun Jul 31, 2016 5:29 pm
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.

Re: Trying to make a raycaster

Posted: Mon Aug 01, 2016 9:59 am
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

Re: Trying to make a raycaster

Posted: Wed Aug 03, 2016 2:37 am
by Positive07
Found this here:
Image

Re: Trying to make a raycaster

Posted: Tue Jan 08, 2019 7:04 pm
by Sarius
There should be more tutorials for doing this in Lua, cause i can't find any as of right now ;(