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
1
Question by TheCraze · May 22, 2011 at 05:35 AM · lightraymirror

Up for a challenge?

(If you don't feel like reading, just skim the bold text)

I have a rather interesting question. It is not some simple question about scripting or model importing, it is more or less a "If you were to do this, how would you accomplish it"

I am currently attempting to create a beam of light in unity, one that will be able to reflect off mirrors and split with prisms.

How would you tackle this problem? I am simply looking for advice.

I would really highly appreciate input, I have been stumbling around attempting to locate something that could point me in the right direction.

Thanks, Craze

EDIT: Here is an example of what I am trying to do: http://i699.photobucket.com/albums/vv357/blobthingy/LightExample.jpg

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

3 Replies

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

Answer by TheCraze · May 24, 2011 at 12:52 PM

I just thought I'd let you guys know I actually created what I needed.

Here is a picture of it functioning in real time at about 750 frames per second: Pic

It is a mixture of all of your ideas really, I doesn't use real angles and functions mainly off raycasting.

Thank you all for your time!

Comment
Add comment · Show 1 · 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 Joshua · May 24, 2011 at 02:48 PM 0
Share

Looks nice. Are you actually reflecting the beams or just rotating them 90 degrees?

avatar image
2

Answer by TheDemiurge · May 22, 2011 at 08:08 AM

I'd probably use particles for the beam itself, I haven't played with their settings in a while but there was a way to make it so they basically look like a solid beam after the initial 'fill' time. A billboarded plane could work as well, it just depends on how you need the beam to look (solid color, color transition, varying colors simulating different materials, etc.)
I'd do a raycast in the original direction of the beam, set to collide with a specific collision layer that would contain all the mirrors and prisms, and then clone the particle object at the point of impact, facing the new direction(s) as appropriate. Having it stop or pass through terrain and other obstacles depends on your needs obviously.

If the layout doesn't change in realtime you can pre-position everything, otherwise raycast a few times per second to adjust as needed. Each new beam could be part of a tree structure, so that every time the original (root) node needs to redo the collisions, it recursively destroys all its children. For easy reflections, I'm guessing the Vector3.Reflect(..) method would probably work (though haven't touched it yet myself).

Alternately, each prism and mirror could have a particle component that can be turned on/off, along with methods that get triggered when a beam hits it, that calculate the direction(s) to reflect or split the beam in. This would save you having to instantiate and destroy objects all the time, you'd just be turning components on and off which is less performance-heavy.

Hope some of this helps, though I'd be happy to hear of any easier or prettier solutions by some of the masters here :)

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 TheCraze · May 22, 2011 at 08:24 AM 0
Share

I would really like to be able to change it in real time, because it really has no use otherwise(besides graphical additions).

Hmm, I appreciate the thought you have put into it, I am going to go play with some raycasting(though I am not very experienced with it).

avatar image TheDemiurge · May 22, 2011 at 08:33 AM 0
Share

Yeah, I had to play around with raycasting too. Be sure to use the versions that take advantage of RaycastHit, since that has all the relevant information. And you'd probably want the bit about the Layer$$anonymous$$asks as well, depending on the kinds of objects you need to 'pass through'.

avatar image TheCraze · May 22, 2011 at 08:45 AM 1
Share

Well, having just started with the ray casting, I am measuring distances between mirrors and making sure they are actually hitting the mirrors.. :p

avatar image TheCraze · May 22, 2011 at 09:09 PM 0
Share

I have made some progress on having the objects aware of rays hitting them, checking the direction it comes from and outputting another ray, but it is still very buggy.. :/

avatar image
0

Answer by UniteMage · May 22, 2011 at 06:03 AM

Simple - Fake it with other game objects.

Thanks CSDG

Comment
Add comment · Show 3 · 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 TheCraze · May 22, 2011 at 06:12 AM 0
Share

So you would have the game object continually extend until it hits another game object?

If it hits another game object it would calculate the angle from there? Would it then create a mesh going off into another direction?

Imagine the texture issues and how the gameobject would react when it has nothing to hit.

I have found one of the more logical ways to approach it is actually to use a particle trail, but I am not quite sure how to make the object react to the angles at such a high speed that it appears to leave a trail resembling a beam of light and not a slow moving object with a trail.

avatar image Bravini · May 22, 2011 at 06:19 AM 1
Share

I can't give you a specific answer as this is far away from my expertise, but I believe what you want to be accomplished would require blob projectors, as the beam can easily be made with spotlights, but the reflection would require shader coding.

avatar image TheCraze · May 22, 2011 at 06:23 AM 0
Share

Logically, the light only has to appear real.. it doesn't require shaders to actually reflect it.

I was assu$$anonymous$$g their must be some way to do this with Rays, but I just am stumped on how to make it behave realistically.

I appreciate the thought though Bravini :)!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Full reflection mirror 0 Answers

Ray Light Effect 2 Answers

My raycast is not always in the forward direction. 1 Answer

Reflect ray of light using mirrors? 2 Answers

How is this effect done? 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