Variable not chaning when exec line comes from on actor hit node.

I have the On actor hit node that is set so when the pawn which is the blueprint in the picture below touches presenttest (an object in the world). But whenever I touch this object and the exec line gets to the setting of presentnum, it just does nothing and skips it. But whenever using the press E key node it works, or if I use a on being play, it also works. Only when using the on actor hit node does the variable not change. Btw this is not a multiplayer game.

You need to show the code :wink:

This test

image

should be in the actor, not the pawn.

When the pawn hits that actor, it can send a message to the pawn to change the value of presentnum.

The actor is being hit, not the pawn.

If you wanted to do it this way around, like you’re thinking. Then you need to find out what is hitting the pawn, and if it’s the right kind of thing ( this is in the player ).

Print strings are always handy. If you put one here

You’ll find the event is not being called.

Actually the on actor hit event is being called. That is why i am so confused. When putting a print string there, it prints just fine but doesnt set the variable even though on actor hit was successfully called.

And a print string right after setting the variable.

Then it has to be how you’re testing the variable elsewhere, I guess?..

the present test is actually a static mesh, and I have a variable in the player blueprint which is the blueprint that was in the picture, and it refrences to the static mesh present

yes
I tried this but the same thing happened. It was triggered but when getting to the variable just didn’t set it

1 Like

Whats also odd is that when printing the variable directly after setting it, it prints it like it was set correctly. But if I set a seperate line that has when hitting the E key to print the variable, it shows that it has never changed.

OK, but you can SEE it is setting the variable, so it must be something else :slight_smile:

How are you making this ‘variable was not set’ evaluation?

yes123
I do this. It tells me the default value of 0 instead of what it was supposedly set to.

It’s very hard to tell with just these snippets of code.

Are you perhaps setting the same variable elsewhere, maybe on tick? ( then it would happen before you could press Q to find out ).

You can right click on the variable and see all places it is referenced.

no, that was the first thing i checked. I just dont understand why it goes back to the default value

You can also set a watch point in the debugger. It will stop the blueprint when something changes it.

how do i set a watch point?



It shows that there is a second firstperson character when I start the game. And it show that the first ones variable did actually change. is there even supposed to be 2 of them?
(this is from the blueprint debugger btw)

It sounds like you’re getting one player by dropping it in the level, and the other from the gamemode.

Just get rid of the one placed in the level…

that sort of worked. Now when I run into the present it activates the event hit but its not getting past the if statement. Did I do this code correct?


(ignore the on actor hit at the bottom I forgot to remove it)


It so close to working. But how do I check if I’m hitting the present, and not the ground or something else. I thought this code would work, but for some reason its coming out as false, I even had it print what I was hitting, and it matches exactly to what it should be checking in the branch node. But for some reason it is staying false.

finally fixed it . Just had to use an on component hit node

1 Like