Branch Output Always False

I’m super new to programming and Unreal my apologies as this is probably a simple oversight by me.

I only want the weapon to shoot when the variable “Magazine” is 1 or more. But if I set the magazine to 10, it reads false. The same thing happens when its at -10. I feel like Im crazy because I would think this would work, at the very least change the outcome from the positive and negative 10.

I don’t see anything obviously wrong, but you might pull off the string pin on the Print String and open a Append node. Then feed the magazine pin into that with a constant saying what it is (like Magazine) so you see the actual value the conditional is evaluating. Might find it’s not 10, then you have another problem to figure out. That would also prove that the Hello you get back is not coming from an errant print string elsewhere.

Another debugging method would be to prove that the branch is working as you expect by doing a Set of the Magazine variable in line between the Triggered and the Branch. Then when it works, you relieve your mind of the branch being the problem and start looking elsewhere.

You need to be careful with “Triggered” because it’s a tick/pulse.

I would connect the node to STARTED if I were you.

At the first Branch, you are checking if Magazine is less than 1 as opposed to greater than.

ps. well done for commenting your code and keeping it tidy! A good habit to get into.

1 Like

Ah, I missed that. Yes, if the player has any ammo on them, they will say “hello”.

But, again, careful with “TRIGGER”; make sure it’s what you want.

This is my current issue. I asked a friend of mine and somehow it works now. This is my current setup, but now no matter what the magazine’s default value is, it always reads 1. Like click, print 1, click, print 0, click, print hello

But wouldn’t that still make it fire if I set it’s default value to -10?

I did get it fixed by doing this. However I also think I have a new problem that would answer why even at negative numbers it wouldn’t fire.

For some odd reason no matter what I set the default value to it always says I start with 2 bullets in the magazine (Magazine is set to 2). But its default value is at like 20.

I don’t know if an image is needed but voila.

Thank you everyone for your responses, I found that the issue was partly solved by Milisours response. However the issue was for some reason the variable didn’t like existing in BP_Weapon_Component. It got set to 2 no matter what I did. I just added the variable into BP_FirstPersonCharacter and casted it and now it all works wonderfully.

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