Raycasting to hit!

Edward Kim
May 30, 2021

As you can see I have gotten a basic Raycast working to hit some targets! (The debug at the bottom right). How did I go about doing it you ask?

In reality it wasn’t as complicated as I had thought it would be.

After creating a new Vector3 called center which would be essentially the center of the screen, we set the Ray Origin to be from our Main Camera from the “center”.

Then we can store what we hit via the RaycastHit! With this I have just set it to do a Debug.Log when a hit is registered but this will stem later into hitting an enemy soon. It surprises me actually how simple it was to get this basic shooting mechanic made.

See you next post!

--

--