Hi there I seem to have hit an error in my coding and need some tips and trix on how to fix it. Let me show you how the code that unity decided is an error.
if(collision.transform.tag == "monster1")
{
health -= MonstersDamage.MonsterDamageAmount[0];
Debug.Log("Why you have to be stab!");
}
In visual studios i don’t seem to see an error but when i try to collide with “monster1” i seem to get about the error message.
For clarfication: It is the line health -= MonstersDamage…line is the error dealer!
ps: I’m new to unity forums is this the right place for help?
No, MonstersDamageAmount could be a float array. MonsterDamage is either a struct or a class, definitely not an array and assuming you are indeed pointing to the right error line, it is probably null right now as it is the only the only obvious pointer on that line that could produce that error message.
I don’t really understand what you mean I am a junior student in programing. But the error code is referring to a socalled NullReferenceException I don’t understand what that is.
NullReferenceException just means that something is null, which means it does not exists, which means it is reference nothing.
There is two possible reasons either
MonsterDamage = null, or
MonstersDamage.MonsterDamageAmount = null