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 Alp-Giray-Savrum · Aug 28, 2014 at 09:04 PM · linerendererhitlaserdot

Drawing "Ray like" objects in game

Hello again, I'm working on red dot stuff.

I've wrote a code for detecting hitdist and etc. but i don't want to see line. I only want to see where it ends as red dot. how can i do that ?

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 robertbu · Aug 29, 2014 at 01:37 AM 0
Share

At debug time, you can do:

  • Only draw the end of the ray (very short line, not a dot)

  • OnGizmosDraw() and Gizmos.DrawSphere() or Gizmos.DrawWireSphere

At runtime or debug:

  • A mesh you create like a sphere located at the hit point

  • GameObject.CreatePrimitive(PrimitiveType.Sphere)

  • Circular texture on a Quad or Sprite positioned at the hit

  • Circular texture draw on the Viewport space using a GUITexture

  • Circular texture draw using GUI.DrawTexture()

And some other choices. There are specifics to make any of these work, but I hesitate to add more information without knowing your goals.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by AKWolf · Aug 29, 2014 at 01:37 AM

Check out Remi Gillig's utility file for drawing debug objects https://gist.github.com/speps/3701541

Works great and no need to clutter your hierarchy with random debug game objects!

If you are looking to only draw something where the ray intersects an object, you can use those utility functions and pass in RaycastHit.point as the position. It is the world position of where the cast hit a specific collider.

http://docs.unity3d.com/ScriptReference/RaycastHit-point.html

Comment
Add comment · 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
0

Answer by AlwaysSunny · Aug 29, 2014 at 01:14 AM

Best way might be Graphics.DrawMesh()

Alternately, you could have an actual quad object you keep around, but only activate it when necessary.

Either method requires a texture and material of a red dot. You'd use hit.point to determine the quad's position in 3D space, probably backing it up by a small amount to avoid z-fighting.

Comment
Add comment · 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

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

24 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

Related Questions

Create a 2D line reflection (laser trace) 1 Answer

Help with LineRenderer 1 Answer

Dynamically adjusting LineRenderer vertexes to follow raycasts 0 Answers

LineRenderer End Width Bug 2 Answers

How to get a LineRenderer to shoot from Gun Point to Mouse Position 1 Answer


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