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
14
Question by welliam · Aug 20, 2012 at 02:18 AM ·

How I can see that ray from Debug.DrawRay ?

Hi, I just stopped at the OnCollisionEnter event and found an example like this:

 void OnCollisionEnter(Collision hit){
         foreach (ContactPoint contact in hit.contacts) {
             Debug.DrawRay(contact.point, contact.normal, Color.red);
         }
         
 }

I tried but...how I can see that red ray ?

Thanks

Update: according to advise from SGamerXxX I modified the code and get the result I want thanks alot:

 Debug.DrawRay(contact.point, contact.normal, Color.red, 20, true);

alt text

untitled.jpg (74.5 kB)
Comment
Add comment · Show 5
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 SGamerXxX · Aug 20, 2012 at 03:24 AM 1
Share

Not sure if this would work, but try turning on gizmos ( Game Window ( $$anonymous$$aximize on Play,Stats,Gizmos))

avatar image sparkzbarca · Aug 20, 2012 at 03:37 AM 0
Share

I THIN$$anonymous$$ you need to call it within update()

the ray is being drawn and disappearing so fast you never see it.

avatar image Eric5h5 · Aug 20, 2012 at 03:52 AM 0
Share

You don't need Update if you add a duration. Turning on gizmos does indeed allow it to be seen in the game view.

avatar image welliam · Aug 20, 2012 at 04:28 AM 0
Share

@SGamerXxX yes that did it !! many thanks my friend. posted as an answer to check it plz

Thanks for all other replay and help

avatar image Khada · Aug 20, 2012 at 07:21 AM 0
Share

be sure to mark the question as answered

2 Replies

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

Answer by SGamerXxX · Aug 20, 2012 at 08:40 PM

Good it worked, here is it an answer form as you requested:

Try turning on gizmos ( Game Window ( Maximize on Play,Stats,Gizmos))

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 asdfa dasdfadsf adf af asd · Jul 13, 2015 at 03:14 AM 0
Share

You must use both... turn gizmos on AND put the third/fourth parameters as well.... gl

avatar image paranoidray · Nov 23, 2015 at 03:01 AM 0
Share

alt text

gizmos.png (91.2 kB)
avatar image
13

Answer by Muuskii · Aug 20, 2012 at 03:40 AM

Well, let me ask you this: Are you looking in scene view? Because that's the only place where it's visible. If you are and you STILL can't see it, first add Debug.Log("Collision"); to make sure the collision is ACTUALLY going off, secondly add a duration to the ray so that it doesn't disappear so fast:

 Debug.DrawRay(contact.point, contact.normal, Color.red, 5.0f);

If you still can't see it and the Gizmos thing doesn't work out. . . I might have to come over to your house ;)

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 jacksonkr · Jan 25, 2013 at 01:50 PM 1
Share

I've been looking all over for this answer and clicking on scene view was it! I'd +1 you but I cant because I only have 1 rep. haha aww :(

avatar image TailKitty · Dec 26, 2016 at 03:46 PM 0
Share

$$anonymous$$ake sure that you are actually Raycasting first and then running your debug piece of code: Debug.DrawRay(contact.point, contact.normal, Color.red, 5.0f);

In my case, I was declaring the Ray and just after was trying to run this Debugging before my raycasting actually happened.

Obviously but still...

So the ultimate recipe is: - Run Debug.DrawRay after raycasting is happened - Turn on Gizmo - Add DrawRay duration

Result: Ray visible as in Scene, as in Game view

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

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

Related Questions

Always play music? 1 Answer

0xFEFF error im new PLEASSE help. Script error 1 Answer

Instantiate cloned prefab to local position of an empty object 1 Answer

Using a string in a C# script in a .js 1 Answer

Zombie Spawner script 2 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