Object reference not set to an instance of an object

Hi guys,
i was made everythink 1:1, like in the course, but now i have problem:

NullReferenceException: Object reference not set to an instance of an object
RPG.Combat.Fighter.Hit () (at Assets/Scripts/Combat/Fighter.cs:46)

How i can fix it ?

1 Like

By making sure it’s not null.

For more helpful answer, it would require some details.

Most commonly, the issue is that the target is currently null, when the Animation Event Hit is called…
If Line 46 in your Fighter Script is dealing with the target, try starting the Hit method with

if(!target) return;
1 Like

Privacy & Terms