Player sprite turns to black when I try to move it.
Hi, I've been working on a 2D brawler and I need to use a new material for my sprites so that I can use my own lighting. Since I changed the material whenever I move my player the sprite changes to black. http://imgur.com/OQhVL32
Even with a light pointing right at the scene the sprite will still turn to black. http://imgur.com/naV5YlR
I am using the Sprites/Diffuse shader and I have changed nothing else from default.(there doesn't seem to be any options on the material??) I couldn't find anything on the internet. Has anyone had any experience with something like this?
Answer by thealexguy1 · Aug 09, 2017 at 09:32 AM
I hope this isn't too late :/ I just found the answer myself! In your code on the player you probably have code changing the localscale:
GetComponent<Transform> ().localScale = new Vector2 (1, 1);
and
GetComponent<Transform> ().localScale = new Vector2 (-1, 1);
Instead, make sure you are setting the scale to a Vector3 with a third 1
GetComponent<Transform> ().localScale = new Vector3 (1, 1, 1);
and
GetComponent<Transform> ().localScale = new Vector3 (-1, 1, 1);
THAN$$anonymous$$ YOU!!! I could literally kiss you right now! THAN$$anonymous$$ YOU <3
WOW!!! Thank you .. been racking my brain on this one!!! Z order was set to 0. Set it to 1 and BINGO!
Answer by Ndiaz · Nov 25, 2015 at 01:20 AM
@theunderstudy I have this same issue. Have you found anything out? Maybe comparing both our scenes will help narrow things down...
Answer by theunderstudy · Nov 25, 2015 at 12:28 PM
Hi, I ended up using something different to get the effect I wanted(Limited time for a school project) I passed an opaque object infront of the camera to give the effect of the players passing through the tunnel. All though it didn't fix the problem, I hope you can use something similar.
@theunderstudy I'm sorry to bother you, but could you elaborate? I'm not seeing a tunnel anywhere in the gifs you posted, so I'm a bit lost as to " the effect of the players passing through the tunnel".
If it helps at all, my game is top-down, rather than side-scrolling. I would gladly post screenshots of the weird behavior, but I'm currently at my day job. I'll have to wait until my lunch break.
@Ndiaz Sorry for the confusion, I wanted to make it seem that they were passing through a tunnel. I didn't have time to fix the issue so I passed an object in front of the train like this: http://imgur.com/U1Vhng3 So I never fixed the problem I just worked around it and used normal material on my sprites. Sorry I can't be of help to you.