Hello guys, this is my error Code
NullReferenceException: Object reference not set to an instance of an object
Mob.attack () (at Assets/Mob.cs:58)
Mob.Update () (at Assets/Mob.cs:41)
The Script where the error code comes from:
Hello guys, this is my error Code
NullReferenceException: Object reference not set to an instance of an object
Mob.attack () (at Assets/Mob.cs:58)
Mob.Update () (at Assets/Mob.cs:41)
The Script where the error code comes from:
lets start with : C# Coding Standards and Best Practices
and: Using code tags properly - Unity Engine - Unity Discussions
it looks like “opponent” doesn’t exist, where do you try to set that?
Can it actually be that it has something to do with the player variable? in Unity i named my character “Player” and not player
ok, capitalisation is important in unity.
Start not start
the word “player” in your script is referring to the Transform reference you set at the top, not the name of the gameobject in the scene (which would be player.name) these are two very difference concepts.
Oh wow, i would have never ever found that!
Thanks!
I’d recommend putting the time into learning the naming conventions (as linked above) and perhaps some of the basic tutorials in the learn section. Getting used to the “normal” way of writing code will hopefully let you spot these things in the future and hopefully avoid them in the first place.
with learning the naming conventions you mean the coding standards?