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 12boulla · Mar 24, 2016 at 04:31 PM · 2dspriteballshine

Unity 2D shiny ball?

Hi,

I am trying to get a 2d effect of a shiny ball. However, I need the ball to be able to roll (not fixed angle on Rigidbody2D). I cannot simply have a texture like this one:

alt text

Because when the ball rolls, obviously the light shiny patch will roll around aswell, which would not happen.

I have tried using lights but have not had success in creating the same effect.

Does anyone know how I can achieve this?

Also, I want to be able to add a shop where you can buy new balls, some have alpha in their sprites. So I can't just have a faded out sprite of the shiny part following the ball unless it is only rendered on non alpha parts (don't know if that made any sense...)

Any help is greatly appreciated, thanks!

ball.png (5.4 kB)
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 Masterio · Mar 24, 2016 at 07:35 PM 0
Share

You can separete shine layer and when ball is rolling then shine sprite rotation is constant and ball rolls.

avatar image 12boulla · Mar 24, 2016 at 10:28 PM 0
Share

@$$anonymous$$asterio thanks for your suggestion. $$anonymous$$y only problem is that I have some balls that have alpha parts to them. Let's say I have a ball with a hole in it. I don't want the shine part to be rendered on the transparent parts of the ball. Thanks.

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by LindermanBR · Mar 24, 2016 at 09:42 PM

Take a look at this video https://www.youtube.com/watch?v=fD_ho_ofY6A Its about Material And this one is about 2d Texture http://docs.unity3d.com/Manual/class-TextureImporter.html

I'm newbie here, but i think if you can apply a metallic texture into your 2d ball the light will reflect properly.

I think what Masterio Said can work but if you have more than one source of light it will not be cool since the ball will not "react" to the lights. Good luck. Sorry for my english.

Comment
Add comment · Show 2 · 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 12boulla · Mar 24, 2016 at 10:29 PM 0
Share

Thanks. Unfortunately I only have Unity 4.6 as I am restricted to a windows vista pc. This method would probably work for 5.0+ though.

avatar image LindermanBR 12boulla · Mar 25, 2016 at 03:17 AM 0
Share

I don't use the 4.6. so i can't tell. Try to see if the sprite you want to use has the option to use textures or materials. Good Luck.

avatar image
1

Answer by TBruce · Mar 25, 2016 at 11:23 AM

@12boulla Add a child object to your 2D ball. On the child object add a "Point" light component. You will need to play with the "Range" and "Intensity" settings to get the effect that you are looking for. Good luck!

Edit: It is important to set the child object Z value for the light to a negative value. This you also need to play around with to get the desired effect. But unfortunately this does not work for a black ball as you have in your example so creating a shine layer as a child object like others have mentioned is most likely the way to go.

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
1

Answer by lauti_nipi · Mar 25, 2016 at 11:31 AM

I would try to separate the shine from the object. I would treat it as another image component and add it to the ball. Making the ball to have two images components, one with the base colour (in your example, black) and on top, another image that will be the shine.

This way you can treat the base colour and the shine as two different colours and with a bit of code, I guess that it might be possible to make the shine follow a light source.

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
1

Answer by Tu-Le · Mar 25, 2016 at 11:36 AM

you mean you wanna roll a 2D ball object without roll it's sprite ?? you can freeze rotation it's Z asix, or set rotation Z asix = 0 in Update()

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
1

Answer by meat5000 · Mar 25, 2016 at 05:27 PM

I dont really do 2D but I came across this little tut on Pixel Lighting.

You can create a depth or spec map and rotate that on its own leaving the texture sprite unrotated. This should give the impression of the ball moving. Think of little specs of light and shadow from little pits in the surface of the ball.

This means you can leave your original texture alone if you want the shine to stay put.

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

72 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

Related Questions

How do you check to see if an animation is playing in a Sub-State machine? 0 Answers

Resizing orthographic camera to fit 2d sprite on screen 1 Answer

Incorrect usage of Vector3.Dot? 0 Answers

Multiple Sprite animations 1 Answer

How do I check if/where in a sprite another sprite is? 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