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 /
  • Help Room /
avatar image
1
Question by Thex_PiedDroit · Oct 25, 2015 at 12:50 AM · raycastraycastingraycastscapsulecast

How to actually make raycast hit colliders it s starting from?

Hi everyone!

I have a very good knowledge of how raycasts work, with the layers and stuff, but today I have a problem that apparently nobody has, or at least they are overwhelmed by the opposite problem so I couldn't find a solution:

I am making kind of an RTS with a non-rotating isometric camera, thus, when units go behind walls, I want to render them in transparency, like this:

alt text

So as you can see, it works fine by now, the only issue is that to do this, I do a capsuleCast from my character to the camera, but as I can go inside buildings, I am currently forced to use a mesh collider on my building or manually place box colliders on all my walls to detect them when I'm inside. Primarily I wanted to simply use a box collider all around the building to optimize the collisions, but of course, if I am inside, the capsuleCast doesn't detect the collision.

Here's a little illustration: alt text

So my question is this: is there a way to actually detect colliders the raycast is done from, please? (I saw something about changing a "Raycast collision inside" parameter or so in Edit->Preferences->Physics, but I couldn't find the parameter)

Also, I'm using Unity 5.2

Thanks a lot for your time!

illustration.png (18.8 kB)
capture.png (44.4 kB)
Comment
Add comment · Show 1
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 Statement · Oct 25, 2015 at 01:18 AM 0
Share

Well written question with clear illustrations. +1

1 Reply

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

Answer by Statement · Oct 25, 2015 at 01:14 AM

Can't you do the CapsuleCast from the Camera to the Player instead of from the Player to the Camera? The Camera isn't inside a BoxCollider and so it can get the detection on the BoxCollider the player is inside.

Eg.. instead of

 if (CapsuleCast(fromPlayer, toCamera)) ...

do

 if (CapsuleCast(fromCamera, toPlayer)) ...
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 Thex_PiedDroit · Oct 25, 2015 at 02:48 AM 0
Share

Hey! Thanks for your idea, it does indeed work, I must admit I haven't thought about it, it's kind of embarrassing. x)

Thanks a lot!

avatar image Statement Thex_PiedDroit · Oct 25, 2015 at 10:00 AM 0
Share

Well, sometimes you have to stop thinking inside the box and think outside the box. ^^

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

32 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

Related Questions

Raycasting is running in two different objects with the same Tag when I touch just one of them 1 Answer

Cursor not staying centered to gameobject 0 Answers

Raycast Not Detecting Hit 0 Answers

Multiple raycasts and only two are working 0 Answers

Ignore Raycast not working properly? 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