Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Preetthefire · Sep 14, 2012 at 02:51 PM · raycastexplanation

Raycast Explanation

Good morning everyone,

I was surfing on web, and i have see raycast, i searched a lot on the unity scripting reference, but nothing explain this nicely.

I have see that we can use for ScreenToRay, what is that?

we can use for detecting if is in the range, how? and why dont use vector3.distance?

we can use for enemy ai scripting? how?

we can use for shooting projectiles? but why dont use instantiation, and apply force on rigidbody?

what is really this raycast? what can i do? and how?

what is the scope? thanks everyone, please tell me more then the web on raycasts!!

thanks have a nice day!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Fattie · Sep 14, 2012 at 04:59 PM

To answer all your question ...

"why dont use vector3.distance" because you do not know what the thing is, or where the thing is. (if you know two points, sure, use distance.) but if you don't know WHAT you are pointing to, you need to find out.

When (example) someone touches a screen, you DO NOT KNOW what is under the finger. this is how you find out. When your character looks out from behind a door, you DO NOT KNOW what direction he is pointing at, this is exactly how you find out. You see? it's like A.I., the first step of A.I.

"enemy ai scripting" ... yes you often use it in many ways for that

"we can use for shooting projectiles" ... not usually, you just use "instantiation, and apply force on rigidbody"

BUT if you are shooting a "laser" or "instant" bullet (the bullet is not actually an object flying through the air, it just does damage in a straight line, you use a cast to calculate the impact point

"what is the scope" it can touch anything, or only certain "physics layers" of the scene - learn about physcis layers (very simple and powerful)

Hope it helps!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Preetthefire · Sep 15, 2012 at 06:51 AM 0
Share

Thank you so much, You helped me a lot!

avatar image Preetthefire · Sep 15, 2012 at 08:15 AM 0
Share

I have Done!

avatar image
0

Answer by avidesk · Sep 14, 2012 at 04:22 PM

Raycast projects a ray (a line or line segment) from a point in 3d space. If that ray hits a collider, it returns information about what it collided with. It can be used for many applications, including the ones you have listed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Instantiate multiple objects and have them raycast 1 Answer

Using Trigonometry for Collision Detection 0 Answers

Why does this script I got from the Unity Document site does not work? 1 Answer

Make Raycast ignore anything that "Isn't" my player(Solved) 1 Answer

How to obtain third person accuracy 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges