I have already assigned the variable but still got this error. Can anybody tell me how? I watched this guy tutorial and he did it with this code so there shouldn't be a problem I guess.
Asked
Active
Viewed 576 times
-6
-
2Please provide [mcve] and not a link to image of your code... – FCin Jul 02 '18 at 06:12
-
1. Please post your code/errors as formatted text instead of a screenshot. 2. Have you tried debugging your code? – Freggar Jul 02 '18 at 06:12
-
Which line of code is it complaining about? – mjwills Jul 02 '18 at 06:20
-
This question is liable to **downvotes** because you didn't provide a MCVE, and you didn't identify specifically the potential causes of the error. – Ṃųỻịgǻňạcểơửṩ Jul 02 '18 at 07:15
1 Answers
2
The problem is that you don't initialize the property private Material material;
When you create object like that you create a reference that points to null
. In your code you are trying to modify this object but since it's not initialized it's null
. The solution is to initialize it in the constructor like so:
public FlowLines()
{
this.material = new Material();
}

Ivan Kaloyanov
- 1,748
- 6
- 18
- 24
-
1or `material = this.gameObject.getComponent
().material;` – Draco18s no longer trusts SE Jul 02 '18 at 16:41 -