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 cmo · Jul 28, 2013 at 12:22 PM · raycastraycastingtransform.positionlinecast

Linecast blocked by colliders not actually in the way?

I'm having trouble with a Linecast that goes from a "sun" object to all the cubes on a board. The Linecast appears to be getting interrupted by cubes that are not in the way of what should be a straight line from the center of one transform.position to another.

Here's an example of what I'm talking about:

alt text

In the above pic, if I remove the cube I've circled, the Linecast hits the target I've pointed to. All of these objects are on the same Z, so that's not the problem.

Here's an example of their Vector3s here:

  • linecast origin: 0.5f, 0.1f, 0f

  • target: 0.4f, -0.6f, 0f

  • blocking: 0.3f, 0.1f, 0f

I'm really baffled. The blocker is actually further to the left than the target. What is happening to the Linecast here?

Just for completion's sake, here's the snippet of relevant code:

      foreach (SideDigScript d in allCubes) {
         Vector3 blockPos = d.transform.position;
         
         if (Physics.Linecast (theSun.position, blockPos, out hitInfo)) {
             if (hitInfo.collider.gameObject.GetComponent<SideDigScript>() == d) {

// bla blah

screen shot 2013-07-28 at 6.09.39 pm.png (70.3 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 illinar · Jul 28, 2013 at 01:39 PM 0
Share

try to use Debug.DrawRay(theSun.position, blockPos) to see whats actually going on.

avatar image robertbu · Jul 28, 2013 at 03:33 PM 0
Share

Raycast is based on the colliders, not the physical object. Turn on Gizmos and click on your blocks in the hierarchy to verify the are the correct size. And follow @cmo's suggestion of doing a Debug.DrawRay() to verify the path of the Raycast.

avatar image Eric5h5 · Jul 28, 2013 at 03:53 PM 0
Share

You'd use Debug.DrawLine rather than DrawRay.

avatar image cmo · Jul 28, 2013 at 04:27 PM 0
Share

Thanks guys -- the colliders are correct size. I've also got gizmos on and have checked placement.

Debug.DrawLine is new to me, much appreciated! I've got it on and can see the problem now. However.. I'm just as confused. It looks like one of the lines stops before it reaches the block.

alt text

So.. Debug is helping show me that something is wrong, but not what it might be. This project doesn't have a lot of code yet, and I've looked over what's there to try to make sure rogue particles or objects couldn't possibly be showing up for a split second. Any ideas?

screen shot 2013-07-28 at 11.13.10 pm.png (243.1 kB)
avatar image cmo · Jul 28, 2013 at 04:31 PM 0
Share

Oops, and I figured it out a second after posting. I'm destroying the old block through code, and the DrawLine is being called first, so it hits the collider while it's still there. Thanks for the pointer to Debug!

0 Replies

· Add your reply
  • Sort: 

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

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

Help with Raycast C# 0 Answers

RayCast or LineCast? 1 Answer

Raycasting along line renderer width 1 Answer

Multiple linecasts question 1 Answer

Ricochet Problem of projectile bullets 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