If statement causes crash when given public int variable

only in UActorComponent and it works when given a locally declared int

  • if statements work in character class when given Local and field int values
  • but in the ActorComponent the if statement works on everything except field declared integers

is this a but or are ints not supposed to be in if statements

this only happens in ActorComponent

if (IntegerValue == 3)
	// do something

Are integers supposed to cause crashes when in if statements

The crash is probably coming from what happens after the if? What does the crash log say?

The crash log just directs me to the exact line the if statement is on

It happens with nothing inside of the if staement

Could it be because of the int

But then again it doesnt happen when it is a lacal int only field


the only way to do such crash is to leave unasigned variable.

make sure you got some value inside this variable. If it crashes right click variable and add watch than check it’s value.

Again make sure you assign value to this variable for example IntegerValue = 1

well i did and it still happened

the if statement only causes crash when i use an int that was declared in the header even if i set the int value in the ActorComponents constructor it still causes crash when in if statement

this question is answered in this

Have you tried launching a debug instance, e.g. from visual studio Debug > Start Debugging, because sometimes it gives more useful information when it catches a crash than the log.

thank you but it was because of how i called the ActorComponent not the if statement Silly me

Thank you anyway

and this was figured out in this