- Home /
2d sprite not properly affected by point light
I've got this 2d sprite with a diffuse shader attached to it moving around a 3d enviroment.
I want this sprite to recieve light everytime he passes under one of the street lights in the scene, so I also added a point light under every street light with the culling mask set to affect only the player and the NPCs. So that works just fine for the player and apparently also for the NPCs, at least while on the scene window. But once I run the scene, only the player sprite is lit up by the point light, the NPC sprite doesn't seem to be affected at all (unless it moves further on the Z axis).
Is this a bug? I need all the sprites to be affected by the light in the same way! Can someone shed some light on this problem? :3
Thanks in advance!
Answer by paugrn · Dec 23, 2017 at 12:22 AM
I finally figured it out!
I was using transform.LookAt(Camera.main.transform.position) to keep my NPC sprite from rotating while moving around, but this also made it flip 180 degrees on the Y axis and, because of that, the side of the sprite supposed to be affected by the light was not visible from the camera perspective. In the end I just erased that line of code and changed the angular speed of the navmesh agent to 0. By doing so, the sprite won't rotate while moving around and will still be facing the camera. Now both the NPC and the Player are equally affected by the point light ;)
Your answer
Follow this Question
Related Questions
Limit Amount of Light Applied to Sprite 0 Answers
(Solved) Batching sprites in a randomly generated dungeon with Diffuse sprites 1 Answer
Get "on screen" color of a texture to use in a legend 2 Answers
How to edit a shader to make it show sprites it's on without lighting? 0 Answers
Using URP how to make sprites lit by 3D Lights again? 6 Answers