Geting an error upon presing play

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

i get this error since i implemented the stop distance,plz help, i tried coppyng your code from gitHub, but it didnt work

Most likely, the target is null. Are you checking to be sure the target is not null before calculating the distance.

True, i notuced it (but due to my lack of knowlage) didnt know how to fix it. Than i watched the next video and sow the instructor had the same bug. I wanted to sudgest you put a notice in the lacture that you are suposed to get the error. But than again that mising piece off info made me think about the code we wrote so far, and how it executes. From what i sow till now in your tutorials (this is my second dev.tv course) , i belive you did it on purpose for that reason. I love your courese thay help me better understand unity and C#, ty for that.

Sry for the long txt with poor grammar, and thank you for the help,

Sandi Lokas

P. S. Hope you are going to continue making great courses for a long time, and i belive this is by far not the last one i am buying :slight_smile:

sub, 25. tra 2020. 21:42 Brian Trotter - RPG TA via GameDev.tv gamedev@discoursemail.com je napisao:

I just started the course and see this problem. FYI, it’s because when the game started, the target is not chosen yet. The Vector3.Distance snippet code work work, so the isInRange variable then refer to null and the error message appears because of the if statement. And whenever you identify combatTarget in the Attack function, the target is assigned and the error message stop appearing.

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

Privacy & Terms