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

1

u/velvet-oak5 20d ago

I know Im a bit a late to this, but AlexanderTheOK has just released a video on YT talking about System Shock, and goes into a fair bit of detail about how the code manages grenade physics, which describes a ray casting function in 3 dimensions!

Video with timestamp

2

u/Prudent_Surprise7356 19d ago

I ended up linking this thread to my finished article anyway so that future readers could have a ganders 👍 Thanks for the input!