I have this skill that uses 20 mana for 1 attack. If i have 100 mana that means i could then attack exactly 5 times and the mana will be then depleted and down to 0. But what happens in reality is that i can attack 4 times and on the last 20 mana that the character has it dont attack 1 more time but instead it uses the last 20 mana and skips the attack animation. How can i fix it maybe with a branch where i say “can attack” if mana is equal to 20 or greater ? I tried many differnt approaches like this but it aways failed
The Mana logic is in a component then added this component is added to the character
From the image I see there are several branches that check the remainding mana even after changing the value.
IMO you only need one branch to check (CurrentMana - SkillCost) >= 0.0: if true then subtract and directly do the rest. You don’t really need any other branch to check the mana since it’s a one time operation where the result will always be above or equal to 0.0.
There is a chance that because of float rounding errors you might get a value slightly less than 0.0, but that is a problem you shouldn’t be concerned with right know, IMO.
I tried with 1 branch then with 2 nothing helps. Can you point me more precise where exactly how and where i need to connect them.
If i do 1 branch like here mana cost is set to 20 and “no mana left?” branch this to true then it cannot attack or if false (mana is left) then it attacks 4 times and skips the last 20 mana but uses it and mana is then at 0 if press attack again it comes the message what my character say “no mana left/ i cannot attack…” stuff like this but same problem
result is not attacking at all… My character says at full mana now directly “mana is too low cannot attack”
If i dont need the last branch on your second screenshot where to hook up the return node should it look like this ? Anyway is still not wanting to attack at all is if i had no mana anymore even if its full
If i change it like this at the end my character its attacking non stop and the skill dont use any mana cost as well as the value is not changing and is aways on full mana now
Looks like it worked best as it was with less or equal then 0 then at least it attacked and stats where moving accordingly so for 100 mana 1 attack -20 mana and it showed correcltly 80 mana. I could repeat that until i get down to 20 mana then it skip last attack and fall to 0 then message comes if i press attack again - character say no mana left…
I get awso the same result. When i use my skill my mana goes from 100 then 80 then 60 then 40 then 20 then 0 and character say at 0 no more mana
Only that it not attack the last 20 mana but just uses it so code is working and display it correctly only why the attack is not doing it at the last 20 mana here how it looks like
yea its the same branch where it has the same condition “no mana left?” which if is true then no mana is left and cannot attack and after cannot attack comes the message. If its false then branch from no mana left? go to “can attack”
So the “no mana left?” if its connected to “can (not)attack” and works correctly acctually the attack im doing on the video should awso work mana cost is at 20 and i have 20 mana left but never uses it only depletes it without attacking
no i cannot consume befor attacking the delay is only for the message if its not there and i click fast with 0 mana character say way too fast “no mana” or cannot attack" which overlaps so when she say no mana it awready say the next message which sounds broken then
If you only do the check once like the image above then the very last consume souldnt be a problem. If there are no other branches checking the available mana then right know I think this is your main issue.
This is all taking into consideration the start value of mana is 100.0 and the skill costs 20.0.
Yeah there is only this 1 branch and the mana shows correctly and depletes until it hits 0 mana then the message comes no mana left so this works as it seems. Mana cost value is set to 20 and is depleting correctly as well only when its at 20 then is broken still dont know what to do with it. is it not fixable as it is right now somewhere in the stats component maybe ? i tried the is greater or equal there but then it dont work anymore
I suggest you try this: after the consume mana function only have 2 print nodes, one on true and another on false. Disconnect everything else. If the print on true executes 5 times (5 clicks) and the one on false executes on the 6th click and after means the problems is elsewhere.
Ok i just try to replicate this on another skill and it seems it has the same issue. When try to lower the mana cost to 10 then it works 9 times and the last time it awso just skips it…
here is the branch result
so it looks like i can use 90 mana and the last 10mana or whatever the skill’s mana cost is then last 10 or 20 mana its counted as “no mana left then”
no i dont use gas system. My stats are on a component self made stuff from tutorials acctually. And everything works except this one all the stats like xp health points and so on work flawlessly so far
The reason last one won’t work because On the basis of “DecreaseMana’s” Result Player is attacking and when the mana reaches 0 in the last attack the ‘Branch inside’ returns false
It is better to rename the output value of the DecreaseMana Function to CanAttack which will remove the ambiguity in your Blueprint and prevents this logical error