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 Esterelle · Mar 27, 2013 at 08:16 AM · c#raycastdebugsweeptest

How to draw a line out which traces the SweepTest ray?

How to draw a line out which traces the SweepTest ray like the one below? I would like to do a SweepTest for diagonal direction (topright), however the angle of the SweepTest direction seems to be off and I would like to find out where exactly is the ray pointing towards. Any kind help would be greatly appreciated!

 void Start ()
 {
     Direction.Set( 1, 0, 0 );
     DiagonalDirection = Quaternion.AngleAxis( 45, gameObject.transform.forward ) * Direction;
 }
 
 void Update ()
 {
     ...
     // Check topright
     if( rigidbody.SweepTest( DiagonalDirection, out hit, 10) )
     {
         ...
     }
     ...
 }
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 Seth-Bergman · Mar 27, 2013 at 08:22 AM

you can use Debug.DrawLine or Debug.DrawRay:

 Debug.DrawRay(transform.position,DiagonalDirection,Color.green);

should do it, you will need to look in the SCENE view to see the line...

Comment
Add comment · Show 5 · 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 sparkzbarca · Mar 27, 2013 at 08:39 AM 0
Share

nope, sweep test x number of raycasts where x = number of vertices in mesh

you could drawray for each vertice using a loop if you wanted to see it.

avatar image Esterelle · Mar 28, 2013 at 03:22 AM 0
Share

Hey, @Seth Bergman, thanks for the help! (:

avatar image Seth-Bergman · Apr 01, 2013 at 05:18 AM 0
Share

@sparkzbarca is right of course, to see the precise area affected you would want to do each vertex.. but the question was just regarding the direction..

avatar image Esterelle · Apr 01, 2013 at 05:43 AM 0
Share

Yup, you're right, therefore I would like to thank the both of you, for helping and explaining what sweeptest actually does to (:

avatar image billunitydev · Feb 13, 2014 at 08:38 PM 0
Share

Well, only primitives are documented as supported by sweeptest (sphere, capsule, and box). A mesh collider won't work.

In addition, I am like 99% sure that box/cube also doesn't work as one would expect.

avatar image
2

Answer by sparkzbarca · Mar 27, 2013 at 08:22 AM

you dont seem to understand what sweep test does.

it's not a ray

it's basically

 foreach (vertice in object.mesh)
 {
 ray.origin = vertice;
 ray.direction = (in your case) DiagonalDiretion;
 physics.raycast(ray);
 with the results stored in a list
 }

more generally your basically moving the object along a path.

If you want what it's doing move the object in the direction. Thats the path. Its every vertice in the object moving in that direciton.

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 sparkzbarca · Mar 27, 2013 at 08:23 AM 0
Share

the point is to cast not 1 ray but a ray for every vertice to see if at some point a vertice would run into something (like a wall)

avatar image Esterelle · Mar 28, 2013 at 03:21 AM 0
Share

Hey, thankyou for the explanation, I now understand what does SweepTest do! (:

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

13 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

Related Questions

RayCast Activating A Button 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Unity c# Raycast axis stuck on one axis 0 Answers

cant kill more than one enemy C# 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