Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Griffo · Oct 12, 2016 at 12:34 PM · raycastraycastinglinecast

RayCast or LineCast?

Hi,

First let me say I've chosen LineCast because I'd read that Linecast will detect intersection even if both StartPos and EndPos are within the collider in a old post in this forum.

I'm generating a flight path and every 0.2 seconds I call a routine that sends out line casts in a 180 degree arc looking for colliders, all works fine until one of the line cast arcs spawns say inside a block, like a tower block, even with the ends of the line cast showing through the block they do not show a detection, has line cast been changed, now on Unity 5.5

Cheers.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by conman79 · Oct 12, 2016 at 05:24 PM

just tested this, and linecast behaves like raycast, ie. the direction matters so it won't register a collider hit if the start position is inside of the collider. If both start and end positions are inside it also doesn't register a hit. I don't know if this was recently changed, but it's way it is now!

I'm working on a project that needs to do a similar thing to yours with ray/linecasts and what I'm doing is using two RaycastAll in BOTH directions to get an array of colliders no matter where the cast starts/ends.

Comment
Add comment · Show 4 · 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 Griffo · Oct 12, 2016 at 07:30 PM 0
Share

Hi, thanks for the input, when you say you are going to use two RaycastAll in BOTH directions to get an array of colliders no matter where the cast starts/ends.

How exactly will that work? I'm doing a bezier curve and checking every 0.2 seconds along the direction of the curve, so you say as it exits the collider doing the raycast at the same position but reversed? That would work just more expense, mobile.

avatar image conman79 Griffo · Oct 12, 2016 at 11:27 PM 0
Share

Ah sorry, I didn't make that clear. I'm not casting from the same position for both rays. The "reverse" ray starts at the end position of the forward ray. So I'm casting from start to end forwards, then end to start (of the forwards ray) backwards. Hope this helps!

avatar image Bunny83 · Oct 13, 2016 at 01:07 AM 0
Share

Linecast and Raycast always worked the same way. It's just a different way of specifying the ray. So neither Raycast nor Linecast has ever detected a collider if the ray starts inside the collider. Any collision surface is a directed surface, It simply doesn't exist when "seen" from the backside. Any collider (with the only exception: the non-convex $$anonymous$$eshCollider ) represent a convex, closed volume. So any ray starting anywhere inside the volume can never hit the outside of the collider.

@Griffo: I'm a bit confused. By "180 degree arc" do you mean you cast something like 180 raycasts, one every degree? While this is possible it's in most cases a waste of processing power. Why don't you simply use OverlapSphere? It will return any collider which bounds intersect with the sphere you specified. If you want to restrict the objects returned you can filter them either based on their relative position or do an additional raycast to the objects center if you need an actual impact point.

You didn't really say for what exact purpose you do those raycast and how you use the results.

avatar image Griffo Bunny83 · Oct 13, 2016 at 05:58 AM 0
Share

@conman79 thanks for clearing that up for me, appreciate it.

@Bunny83 sorry I didn't make it more clear, 180 degree sound to complicated but I only send out a LineCast 7 times starting at -Vector3.right and adding 30 degrees each time, I've attached a picture so you can see what I'm doing.

I generate a bezier curve a random amount of times, each new start position becomes the last bezier curves end position and I divide each bezier curve into 100 points, then I keep adding the points to a list, when the whole flightpath is generated it tells the iRobot its finished so he can go flying.

I also send a LineCast down from the flight point 2mt to check the flight path is not to close to the floor, in the picture that have a small yellow sphere at the ends, just for my visual debugging.

All this is called from a routine every 0.2 seconds.

If any of the LineCasts detect a collider I then delete that bezier curve and a new one is generated, and so on until no collisions are detected.

@Bunny83 you may be able to help me with another problem I posted on this forum HERE I appreciate your help and I'd appreciate anymore you can give, thanks.

PS .. The white Vector3.up's every flight point you can see are again for my visual debugging when trying to get the rotation (roll) of each fight point, in my other problem.

![alt text][2]

alt text

screen-shot-02.jpg (283.9 kB)

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

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

Related Questions

Raycasting along line renderer width 1 Answer

Multiple linecasts question 1 Answer

Ricochet Problem of projectile bullets 0 Answers

Linecast blocked by colliders not actually in the way? 0 Answers

Help with Raycast C# 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