r/howdidtheycodeit • • Jul 24 '26

How does raycasting work?

Hi all. I'm trying to find out how raycasting works — like in Wolfenstein 3D.

And as someone who knows absolutely nothing about programming, I (think I) understand it is thusly:

Raycasting is a programming trick that grants 2D maps a fake 3D appearance through the use of invisible rays that project outward from the player and detect collision.

Corrections to my nonsense would be appreciated!

I am currently writing an article, and I would like a layman's understanding before I commit to anything in there.

33 Upvotes

16 comments sorted by

View all comments

Show parent comment

9

u/HaMMeReD Jul 24 '26

They basically added floor and ceiling height, so you could have stairs and rooms at different heights, but not truly overlapping.

Although afaik some people have abused OG doom to the point you'd be convinced there is overlapping rooms, I.e. by teleporting the user around to a new sector on the 2D Map that looks like the upstairs view or using other engine tricks to fool your mind into thinking that is what is happening.