I’m having a problem with making a particle effect play using Shuriken via Javascript.
The error.
And here is the code:
I’m having a problem with making a particle effect play using Shuriken via Javascript.
The error.
And here is the code:
This:
script = GetComponent(Player_Movement); //line 20
Should be:
movementScript = GetComponent(Player_Movement); //line 20
EDIT: Also, just for the record, it would be much better if you learned how to debug basic code by yourself. In this case, it’s saying that one of the reference types in ApplyDamage was null. This is either movementScript, playerBlood or renderer. All you need to do is make sure they are all set away from null correctly. Also, you typoed line 38 as well.
Thank you for pointing that out, I hadn’t noticed before as the health still worked fine. playerBlood is null. How do you set it away from null?
You set it away from null by setting it to anything other than null. If it’s holding a reference to a particle system, it is obviously no longer null. Beyond this obvious advice, there is nothing more I can do without seeing more than that script. If your game object has a Component of type “ParticleSystem,” playerBlood should be set to it in “Start” already. It either has a Component of a different type or no Component. Alternatively, something else could be setting it to null.
Well, the slot for a particle system is filled with a particle system, however, on play, the particle system is removed.
Are you assigning the particle system in the inspector and setting it in Start?
Is that possibly a prefab and did you create a custom inspector for that? If yes, serialization might be destroyed (meaning not set up) and thus your gameObject resets to default values pulled from the prefab.