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
3
Question by jc_lvngstn 1 · Apr 28, 2010 at 01:51 AM · linerendererquadlaserbeam

How to draw beams?

Such as homeworld, etc. The "Beam" is likely a simple quad stretched between two points, where the Z axis is always rotated to face the camera. (fyi I'm not certain the particle system would work in this case, as it's not as straightforward to generate an exact beam between two points, and I haven't had much luck generating a solid beam of particles. I might look into this a little more, though)

The challenges as I seem them are:

  1. The texture will be stretched the longer the beam. I would likely want to tile the texture instead. A solid beam wouldn't matter, but a beam with energy waves would need to be tiled.

  2. It seems like the beam's Z Axis would be rotated to face the camera, so you always see the full flat beam, not a flat poly if you are a low angle.

The way I think I would go about this is:

  1. Find the distance between the beam emitter and the target.
  2. Create a quad of that length, and the width of the beam.Not sure just yet how to tile the texture depending on the length of the beam/quad.
  3. Find the y rotation difference between the two points, and rotate the beam that amount.
  4. Do the same for the x axis.
  5. The Z rotation would depend on the location of the camera in relation to the Z axis...if that makes any sense. In my head...it almost seems like the beam's Z rotation will always be perpindicular to camera view angle.

Anyone have any suggestions on going about this?

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

2 Replies

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

Answer by e-bonneville · Apr 28, 2010 at 02:30 AM

I've got one simple solution - use Unity's built in Line Renderer, the docs for which are found here.

Comment
Add comment · Show 5 · 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 jc_lvngstn 1 · Apr 28, 2010 at 02:32 AM 0
Share

Thanks! I completely forgot about the line renderer. I think part of my brain filed it under "drawing 1 pixel lines". Silly me. I'll check it out, and see if it meets my needs.

avatar image jc_lvngstn 1 · Apr 28, 2010 at 02:38 AM 0
Share

This looks like it will be perfect. I assume in order have a "flowing" effect, you will just swap out textures, each one shifted slightly?

avatar image e-bonneville · Apr 28, 2010 at 03:19 AM 0
Share

Yeah, that should do the trick.

avatar image e-bonneville · Apr 28, 2010 at 03:19 AM 0
Share

Vote up and accept answer?

avatar image jc_lvngstn 1 · Apr 28, 2010 at 12:19 PM 0
Share

Thank you, elbon96!

avatar image
-1

Answer by 3dDude · Apr 28, 2010 at 01:58 PM

the way i do it is i use raycasts first create a empty GameObject then make a cylinder scale its z axis to .5 then rotate is 90 degrees on the x then make it a child of the empty gameObject set the x position and the z position to 0 then make the z to .5 so that the empty gameObject is at the very back of the empty gameObject. the code attached to the empty gameObject should be:

function Update () { var hit : RaycastHit;

if(Physics.Raycast(transform.position,transform.TransformDirection(Vector3.forward),hit)){ var distance = Vector3.Distance(transform.position,hit.point);

 transform.localScale.z = distance;

} else{transform.localScale.z = 5000;}

}

So i don't know how to make it have a texture but you can use a plane or somthing that will work with a texture. but make the y 1 not 0.5.

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

No one has followed this question yet.

Related Questions

Laser using line renderer 1 Answer

Laser scanning effect 2 Answers

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

Dynamically adjusting LineRenderer vertexes to follow raycasts 0 Answers

Line Renderer. How to lock z axis for side scroller? 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