Answered
0
0

I am currently working through the FMOD Survival Shooter Tutorial. I recently rewritten the code into the enemy_health script which would call the Hellphant hurt event when the enemy was hurt. However, when I play the game, the guns bullet pass through the enemy characters and I am given the following error message:

” NullReferenceException: Object reference not set to an instance of an object
CompleteProject.EnemyHealth.TakeDamage (Int32 amount, Vector3 hitPoint) (at Assets/_Complete-Game/Scripts/Enemy/EnemyHealth.cs:61)”

“CompleteProject.PlayerShooting.Shoot () (at Assets/_Complete-Game/Scripts/Player/PlayerShooting.cs:111)”

“CompleteProject.PlayerShooting.Update () (at Assets/_Complete-Game/Scripts/Player/PlayerShooting.cs:49)”

How would I go about fixing this ?. I am also using a mac if there are any potential inconsistencies.

Thanks

  • You must to post comments
Best Answer
0
0

NullReferenceException means that you are trying to perform an action on an object that has not been assigned/initialized. Unity does a good job of telling you exactly where these issues come from in the console window.

Eg.
Assets/_Complete-Game/Scripts/Enemy/EnemyHealth.cs:61 refers to Line 61 of the EnemyHealth.cs file. You can either attach a debugger as you run the project or even use print logs to see what variables have been assigned at that time.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.