Help with Attacker newAttacker

I’m having an error with the code given in the lecture:

here the attacker.cs:

image

Hi Bifrost,

Is there an Attacker component attached to the object referenced by the attackerPrefab? Which version of Unity do you use?

If you cannot make this work, I would suggest to assign the instantiated game object to a variable of type GameObject and call GetComponent<Attacker>() to get the reference to the Attacker component. Do you actually need it?

Remember you can also look at the lecture code changes via the link in the Resources of each lecture.


See also:

Check your parameters. I think the 3rd parameter should be a Quaternion not a Vector3.

It seems to me that you haven’t changed your attackerPrefab to be of type Attacker. At this point you have “GameObject attackerPrefab” and Unity can not convert GameObject into an Attacker.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms