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 NeoDragoon195 · Jan 17, 2018 at 11:32 PM · unity 5raycastgizmos

How would you make a ray collide with a Gizmos sphere (float)

I need help with trying to make a ray cast hit a gizmos sphere(float) and tell me that they are colliding. I could use colliders but I'm trying to avoid that, because I want to keep those for physics not for scripted actions and I don't want two collider components on one object.

Comment
Add comment · Show 2
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 getyour411 · Jan 18, 2018 at 02:24 AM 0
Share

What is a "gizmos sphere(float)"? It is a very common scripted action to shoot a ray into the world and see what it hit.

avatar image NeoDragoon195 getyour411 · Jan 19, 2018 at 04:26 AM 0
Share

Gizmos are used form seeing things in the editor. I could just use the collider but I'm trying to find a way to get it to interact with a field that I can set and I want the physics collider to only interact with physics objects and not the interacter.

1 Reply

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

Answer by NorthStar79 · Jan 18, 2018 at 05:43 AM

if you mean Gizmos.DrawSphere you can not detect it with ray (nor colliders), they are only for debugging and they can not interact with physics. also hey will not work at all once you build your game. again; gizmos are only for visual debugging for use in editor only,

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 NeoDragoon195 · Jan 19, 2018 at 04:18 AM 0
Share

I know that the can't detect the gizmo its self but I want to know how or if you can have the ray collide or inform me if it hit's the floats range.

avatar image sparkzbarca NeoDragoon195 · Jan 19, 2018 at 04:55 AM 0
Share

I know your saying you understand you can't detect it, but your also saying can you have it collide :P

The easiest way to do this is to just create an actual sphere in it's place.

use gameobject.instantiate()

to create a sphere there ins$$anonymous$$d of a gizmo and add a sphere trigger collider. now you can do that.

avatar image NorthStar79 NeoDragoon195 · Jan 19, 2018 at 05:26 AM 1
Share

you can not use rays for checking them if they hit the float range too. you can implement your own logic with c# for example, you can draw an imaginary line with Linear equation and check some points on that line if it equals your target. but that will be CPU intensive for your game if it is written with c#. on the other hand sphere colliders and rays are reasonably cheap processes.

avatar image NeoDragoon195 NorthStar79 · Jan 19, 2018 at 06:19 AM 0
Share

Okay thanks, I was thinking about using a equation, but if its cpu intensive the I'll just use a collider.

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

175 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 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 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

c# Raycast going off at odd angles. Unity 5 2 Answers

RaycastHit.normal 1 Answer

Raycast do not detect when distance is closer or further than the max distance 1 Answer

RaycastHit2D.collider is null - why? 1 Answer

Why UI layer is being ignored by the raycast? 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