- Home /
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:
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!
You can separete shine layer and when ball is rolling then shine sprite rotation is constant and ball rolls.
@$$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.
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.
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.
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.
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.
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.
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()
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.