- Home /
3rd person shooter shadow problem
Hi everyone.
I'm using the 3rd person shooter of unity 3, but now i removed the direction lights of the scene and placed point lights. And when my player died, Unity gives me a error:
NullRefenceException
CharacterShadow.LateUpdate ()(at Assets/Demo Scene Script/CharacterShadow.cs:168)
What should i do te fix it? Someone can help me?
**EDIT:*
The error says something about this line
child.camera.targetTexture = shadowmap;
Projector proj = (Projector)child.GetComponent(typeof(Projector));
proj.material.SetTexture("_ShadowTex", shadowmap);
Answer by Waz · Jun 26, 2011 at 11:55 PM
Look at that line of code. You'll find it trying to find the direction of the directional light, which you have deleted, hence this error. How do you want the shadow to look with your lights?
Okay i understand it right now, but what should i do then? But what do you mean with, How do you want the schadow to look with your lights?
I'm using pointlights, so i don't know. It's a building with PointLights.
You really need to be able to follow the compiler's complaints yourself. You are given the line number, you have the code, a "Null Reference Exception" means you're trying to access something (eg. that child
variable or the camera
the code refers to). Somehow you've busted one of those. Look back in the code.
Otherwise, don't try hacking on code you download until you understand the code. The demos as tutorials are there to $$anonymous$$ch you, not to give you a start towards a game.
But i want to discover and develop my experience with Unity, So that's why i'm asking this question to know how to work on a project on my own and to know what's wrong if i have the same problem.?? :S
This is why i'm asking. Why are these tutorials here, were are they for? I think to learn about Unity. So how can i make a new project without experience???
The most you should do with a tutorial is add a couple of features, perhaps ones suggested in the tutorial's docs. Then you should do another tutorial, then another. Then you should start from scratch and make something very simple but using the knowledge you have learned from doing the tutorials. Stop that project when you have learned enough, and start another more complicated. Repeat until what you're making is awesome.
This might seem a longer path. But it's the only one that goes anywhere.
See how this person is just making very small things to start.
Okay, that is his own way to discover Unity and i'm do it on my own way. Do you want to answer my question? Yes or No. I would like to receive answers. Not to $$anonymous$$ch me what i should to do with Unity.
Your answer
![](https://koobas.hobune.stream/wayback/20220612122815im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Indie and Static Shadows 3 Answers
Can transparent textures be lightmapped? 2 Answers
No real-time shadows after porting to Unity 3 1 Answer
CharacterShadow script with transparent cutout shader 0 Answers
How to use a shadow projector 1 Answer