I'm getting these 2 errors

This is the first error is this:

This is line 47:

And this is the indexing of the zombie arms:

The second error is this:


I have not even referenced or have done anything with Zombie Stink in the code. Clicking on the error brings me to line 52:

And this is the zombie stink:

Could somebody please help me solve these errors.

Hi,

For which course and project is this? Unfortunately, I don’t recognise that model.

That is an asset of my own. It is for the 3D Unity Course and is for the tower defence project.

Also, the Do Death Physics script in the screenshots above is a script that I made by myself which is something that happens when a zombie dies.

I should mention that despite these errors, the fall arms method works normally.

The fall arms method makes the zombie’s arms fall down by disabling the kinematic in the rigid body and breaking the arms away from their parent.

Well, the error message says there was no Rigidbody attached to your Zombie Stink game object. Apparently, your code or something else you used is looking for that component. Try to add the component.

Well, adding a rigidbody did ‘fix’ the problem. The error stopped popping up but I literally have no idea where I am even calling the Zombie Stink’s rigidbody. And the fact that it takes me to line 52 is even more boggling.

Anyways, about the other error, Unity states in the doc that the error will only appear in this scenario:

However, the transform has 5 children as can be seen in the Zombie prefab images above. Also, in my code, I am not using an index argument that has a value larger than the number of children. Or is the problem coming from this snippet of code from another script in the game:


Is the message repeatedly being sent since the health is less than 60 and particle collisions still happen? The arms still fall as expected.

Add a Debug.Log to the code block to figure that out.

I never use SendMessage because Unity’s Send* messages have got a bad performance. According to the docs, they are fine for prototyping. If you do something more complex, consider implementing a proper event system.

I do not know where your code tries to access non-existing children. Add Debug.Logs to narrow the problem down.


See also:

I am thinking that this is an issue with the GetChild returning the Stink and not the right arm as you expect.

This topic was automatically closed after 14 days. New replies are no longer allowed.

Privacy & Terms