Creating Bullet Holes via Raycasting

Josh Watts
Aug 3, 2022

--

In this article we will look at creating bullet holes when we hit a wall. Than we want to shoot through the center of the screen where our reticle is .To start off we will create a script called shootBehavior and attach it to our Player.

To do this we can use the following code.

The center of the viewport is 0.5 on the x and the y. Than we can use this to shoot a ray from. After that you might be tempted to just use the Quaternion. Identity as usual but that would create this.

It creates a very wonky sort of effect what we want instead is the rotation of the normal of the thing we hit. This is what we get now.

That is much more effective.

--

--

Josh Watts

Hello I am an aspiring game developer learning to develop great games. Right now I am going through a program with GameDevHQ. My favorite game is Half-Life.