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
1
Question by 1337GameDev · Mar 07, 2013 at 10:49 PM · collisioneffecttransparentglowshield

Creating ship energy shields effect

I am wanting to create an energy shield for ships in my game. I know I can create a simple collider / mesh for the shield and set it to invisible (or disable renderer) and then re-enable the renderer when it gets hit and then instantiate a ship shield collision effect prefab for the shield, but i am curious how to avoid instantiating a prefab of a shield effect.

I heard in another forum (this one): Forum post that i can do this.

If you are doing a spherical shield, you can probably put a sphere around your ship, then via script change the color and alpha where there is a collision. I believe the Space Dock widget from the widget contest did this.

How would i achieve this? If a shader is needed, how can I make one with strumpy shader editor?

The qualities I plan to achieve are the following:

  1. An almost transparent sheild

  2. When hit, the shield at the collision location glows and becomes less transparent and then fades back

  3. An effect that can be added to the collision area (maybe using a prefab or emitter)

  4. Mobile kept in mind, so efficiency is a concern

  5. Not permanent / static (on a moving object and shield has health)

An example images of what I'm looking for:

Example

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
2
Best Answer

Answer by Loius · Mar 08, 2013 at 02:54 AM

To get only the collision area to glow, you'll need an effect which occurs at the collision point (well, duh, but i'm getting to something). So if you get hit from front and back at the same time, you probably want to have the effect occur in two places, animating independently. All of that sounds like you'll really want to have multiple copies of the effect waiting to happen (instantiate them 'off' at the start, then activate them as necessary). It might be possible to use a single shader on a single sphere and grant it some spherical, multi-point glow, but that sounds extremely complex to me.

Probably the very simplest way is to create a simple ring shape in a modeling program, animate it as desired (could be as easy as scaling and moving a single bone), and run that animation whenever your want the shield to flash. Set the animated object's size to match the shield size and rotate it to face the impact point before playing the animation.

A more complex way, which can be made to make a far more 'beautiful' effect, is to use an alpha cutoff shader on a stepped-transparency image, like this one:

alt text

Put it on a curved surface, rotate the surface to face the impact point, and then set the material's cutoff value from zero to one to zero over time. Using Unity's default cutout shader, the code is renderer.material.SetFloat( "_Cutoff", value );

The drawback with the image method is that you'd need to add in a second cutoff to create a range of transparencies to display, if you want a 'ring' effect. It's also more complicated to create transparencies in a meaningful pattern like the multiple rings in your image.

And one last thing, if you use one of these methods, and have rings, and have two hits near each other, the effects can overlap and create interlocking rings. You could get around that by messing with the meshes and UV coordinates, or with a complex custom shader. I don't have the maths skills to be much help with that, though.

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 BenKurdziel · Mar 08, 2013 at 02:14 AM

Any ARGB or RGBA files have alphas. Of course, jpg's don't support transparency, so you'd need to use a png formatted material if you are importing a material. Apply the material to the sphere like you normally would, and adjust the alpha however you please for the initial value (invisible if you like).

Then, I believe the code you need will be something along the lines of:

renderer.material.color.a = 'whatever you want the alpha value to be here'

What this is doing is accessing the rendering component of your object, finding the material on it, and adjusting the alpha of the color attribute. I don't remember the range, though I suspect it's probably 0-255 like any of the other RGB Values.

Preferably, place this script on the sphere and make sure it has a Sphere Collider set to "is trigger", and check for:

 function OnTriggerEnter (other : Collider) {
         
         if (other.gameObject.tag == 'tag of item that hits ship')
         {
             this.renderer.material.color.alpha = 0;
         } 
 }


you can do another if statement of course if you want different code for different objects that hit it, or if you want the same code for multiple objects you can use "||" which means OR, which is done by holding Shift and Backward Slash at the same 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 Chronos-L · Mar 08, 2013 at 02:31 AM 0
Share

How about the only the collision area glows, I think that will require a more advance shader to achieve this effects, and I even doubt that whether this effect can be achieved or not.

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

13 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

Related Questions

Fired projectile collision with player issue 1 Answer

Neon light or LED light 1 Answer

I want only the edges visible on my cube? 2 Answers

How to add atmospheric glow to a planet 2 Answers

Glow effect on transparent object 2 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