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
1
Question by jimmyismike · Aug 04, 2012 at 01:13 AM · raycastshootingtutorialnew

Raycast Shooting Help

Can someone here give me a link to a tutorial on shooting with raycasts? I don't want wanna script from anyone unless its bare to the bones. I don't know to much about raycasts if anyone can point to a video tutorial or somewhere helpful in unity documentation that would be great. Thank you -jimmyismike

Comment
Add comment · Show 1
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 jimmyismike · Aug 04, 2012 at 01:43 AM 0
Share

Can anyone out there help out?

1 Reply

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

Answer by speedything · Aug 04, 2012 at 01:50 AM

http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html

Think of it this way...

 var hit : RaycastHit      // This will store the thing we hit with our Raycast
 if(Physics.Raycast        // If we hit something
 (transform.position,      // Start the ray from this transform's position
 transform.forward,        // Fire it forward
 hit,                      // Save the thing we hit in the the variable we created
 100)                      // This is the length of the ray we fire

If the ray we fire hits something then we now have the RaycastHit variable hit. We can now use this to access the object.

 hit.collider.transform    // This is the transform of the object we hit. Do with this as you will!
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 jimmyismike · Aug 04, 2012 at 06:34 AM 0
Share

Thank you that helps.

avatar image Armoth288 · Jun 29, 2014 at 11:16 PM 0
Share

This definitely explains it better than most of the other posts I've looked at have said. Thanks :D

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

8 People are following this question.

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

Related Questions

Raycast shoot not working properly 0 Answers

How to access component that the raycast hit 1 Answer

Raycast chase player, avoid walls.. raycast detailed C# tutorial? 0 Answers

Raycast shooting for multiple weapons 1 Answer

How do i make a Railgun style effect with a raycast shot? 1 Answer


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