• 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 D3m0nE · Mar 31, 2013 at 05:33 PM · physicsraycast

How To Make The Raycast Thicker!

Hello Everyone i want to know how to make the Raycast Thicker

i use this code

 if(Physics.Raycast(transform.position + new Vector3(0,0.6f,-1.6f),transform.TransformDirection(Vector3.forward),out hit)){    
 
 
 }

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

3 Replies

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

Answer by TonyLi · Apr 01, 2013 at 01:33 PM

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

 float thickness = 1f; //<-- Desired thickness here.
 Vector3 origin = transform.position + new Vector3(0,0.6f,-1.6f);
 Vector3 direction = transform.TransformDirection(Vector3.forward);
 if (Physics.SphereCast(origin, thickness, direction, out hit)) {
     ...
 }
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 Tarlius · Apr 01, 2013 at 02:39 PM 0
Share

I didn't realise a SphereCast worked this way! I thought SphereCast was the same as CheckSphere >< Purged my silly suggestions and rating you guys up :)

avatar image araz01 · Mar 20, 2020 at 12:05 PM 0
Share

how do i see a debug.drawray of it? tanks!

avatar image
0

Answer by insoluzioni · Feb 18, 2020 at 01:44 AM

And for 2D projects, you could use CircleCast :)

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
avatar image
9

Answer by Eric5h5 · Mar 31, 2013 at 05:42 PM

You can't make a raycast thicker; a ray by definition is one-dimensional. You can try using a spherecast instead.

Comment
Add comment · Show 6 · 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 D3m0nE · Apr 01, 2013 at 12:53 AM 0
Share

more info about spherecast Please? can you right the C# code

using my vectors

avatar image Eric5h5 · Apr 01, 2013 at 01:02 AM 3
Share

Just look it up in the docs.

avatar image D3m0nE · Apr 01, 2013 at 01:57 AM 0
Share

so spherecast is same as raycast but thicker?

avatar image Tasty Risotto · Apr 01, 2013 at 02:15 AM 0
Share

spherecast is spherecast. you can use multiple raycasts(like 3 or 4) in a small area to simulate a Thicker raycast.

avatar image D3m0nE · Apr 01, 2013 at 11:26 AM 0
Share

i want thicked raycast because i need this :

when i'm aim on the box, will show GUI.label "its a Box"

but with raycast its only show when i AI$$anonymous$$

i need it to showup when the box in range around the raycast

any ideas? and sry for bad english

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Physics.CapsuleCast Help 1 Answer

Raycast stops working after ~40 seconds when target has Rigidbody 2 Answers

Unable to set collision layer from scrip 0 Answers

Is Physics.Raycast deterministic? 1 Answer

Make a rolling ball always on ground without falling when reaching the edges of the map 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