Raycasting to hit!

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!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store