Raycast in Unity

3rd Person Zombie Shooter

Objective: Create a raycast using main camera

Here, center defines the center of the screen, rayOrigin defines the the point from where the ray is being cast.

Then define the RaycastHit variable which will then store the reference to the object being hit by the ray

And finally create a raycast which starts from rayOrigin and defines the Hit object which can then be used to define the type of object and what can be done with it. Here, only the name of the hit object is being displayed.

--

--

--

Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Set up EKS cluster in AWS

New generation IT operations a practitioner’s view

My Code Plateau Experience so far

Single Sign-On With WSO2 Identity Server

Fuzz testing: Beginner’s guide

Business language

https://www.google.com/url?sa=i&url=https%3A%2F%2Fblog.languageline.com%2Fuk%2Ffive-business-languages-youll-need-to-connect-with-customers-in-2020&psig=AOvVaw1ovfrGBgMJDeJLHcdUDXJB&ust=1647774590426000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCNir1e-E0vYCFQAAAAAdAAAAABAD

Implementation of SSL Pinning

Cross-Origin Resource Sharing (CORS) in Depth

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
Niraj Karki

Niraj Karki

Unity Developer

More from Medium

Light Probes in Unity

Ledge Grab System in Unity

Using Height Maps and Pixel Displacements in Unity

Cinemachine and Group Targets in Unity