For the health bar, here is an alternate method: postStep = (e)=>{ pos = [_min + ((_max - _min) / 2.0) / _maxHP * _currentHP, pos(1)]; size = [_size / _maxHP * _currentHP, 0.25]; colorHSVA = [120 / _maxHP * _currentHP, 1 , 1 , 0.5]; } _min is the left x position of the HP bar. If you don't know what that means, just take the *x pos - x size / 2.0* _max is the right x position of the HP bar. If you don't know what that means, just take the *x pos + x size / 2.0* _size is the x size _maxHP is the maximum HP _currentHP is the current HP Note 1: x size means the first index of the size. Like if size is [-5, 16] then x size is -5 and y size is 16 Note 2: if your max HP is say 100, make sure to put _maxHP = 100.0. There is a weird thing in algodoo that if you do 31/10 it will return 3 instead of 3.1. To fix this, you need to do 31/10.0 :)
The script for the health bar worked but after I tried to make something to damage the marbles like you did, both of the marbles' health bar magically disappears, leaving the black bar behind only. And the marbles didn't even touch the damager. Also, both of the marbles I made seem to lose health together at the same time and I can't figure out why
The script for the health bar worked as a charm but after I tried to make something to damage the marbles, it didn't work tho, the health bar magically disappears, leaving the black bar behind. Also, both of the marbles seem to lose health together and at the same time, this inevitably forces me to retype _Health = 10 at the console everytime and I can't figure out why...
I think that the reason that both marbles seem lose health simultaneously is because you forgot to rewrite the second health bar to track the second marble and instead made both of them track the same marble. Also make sure you spelled health the same way in both circumstances. When you divide numbers in Algodoo, make sure that at least one of the two numbers is a non-whole number or else Algodoo will automatically round it to the whole number. for example: don't type "_Health/10", type "_Health/10.0". As for the health bar disappearing, I've never encountered something like this myself before, but I recommend testing the scene with the health bar's script menu open. This way you will see if it actually gets destroyed or if it's just position incorrectly, since the script menu will automatically close when the object it's connected to gets destroyed. If that doesn't work, try slowing adding in the elements/code and testing the scene for every new line of code you write to identify exactly what causes the problem. I hope this helps
@ta_kuann instead of dividing colorHSVA by 12, divide it by (120÷maxhealth) For example, if it has 20 health, set the colorHSVA to [_health/(120÷20),1,1,1]. Which equals [_health/6,1,1,1]
For the health bar, here is an alternate method:
postStep =
(e)=>{
pos = [_min + ((_max - _min) / 2.0) / _maxHP * _currentHP, pos(1)];
size = [_size / _maxHP * _currentHP, 0.25];
colorHSVA = [120 / _maxHP * _currentHP, 1 , 1 , 0.5];
}
_min is the left x position of the HP bar. If you don't know what that means, just take the *x pos - x size / 2.0*
_max is the right x position of the HP bar. If you don't know what that means, just take the *x pos + x size / 2.0*
_size is the x size
_maxHP is the maximum HP
_currentHP is the current HP
Note 1: x size means the first index of the size. Like if size is [-5, 16] then x size is -5 and y size is 16
Note 2: if your max HP is say 100, make sure to put _maxHP = 100.0. There is a weird thing in algodoo that if you do 31/10 it will return 3 instead of 3.1. To fix this, you need to do 31/10.0
:)
how are you so good at scripting?
...
@@CyanBeast01 uhm
Perfect script
Imma sub on him cuz why not?
Thank you
tysm!! i learned how to make a tuna fish game with this method! ps i subbed!
Thanks for the tutorial brother
Bro this guy deserve more subcribe then this!
I want to learn this marble stuff but it;s too difficult
i had no idea how to code and this didnt help me much, tysm! im subbed! i even learned how to make a tuna fish game with this method! :D
Thanks for tutorial
Nice tutorial
The script for the health bar worked but after I tried to make something to damage the marbles like you did, both of the marbles' health bar magically disappears, leaving the black bar behind only. And the marbles didn't even touch the damager. Also, both of the marbles I made seem to lose health together at the same time and I can't figure out why
The script for the health bar worked as a charm but after I tried to make something to damage the marbles, it didn't work tho, the health bar magically disappears, leaving the black bar behind. Also, both of the marbles seem to lose health together and at the same time, this inevitably forces me to retype _Health = 10 at the console everytime and I can't figure out why...
I think that the reason that both marbles seem lose health simultaneously is because you forgot to rewrite the second health bar to track the second marble and instead made both of them track the same marble. Also make sure you spelled health the same way in both circumstances.
When you divide numbers in Algodoo, make sure that at least one of the two numbers is a non-whole number or else Algodoo will automatically round it to the whole number. for example: don't type "_Health/10", type "_Health/10.0".
As for the health bar disappearing, I've never encountered something like this myself before, but I recommend testing the scene with the health bar's script menu open. This way you will see if it actually gets destroyed or if it's just position incorrectly, since the script menu will automatically close when the object it's connected to gets destroyed. If that doesn't work, try slowing adding in the elements/code and testing the scene for every new line of code you write to identify exactly what causes the problem.
I hope this helps
Or maybe you set "_Health" to be 0 at the start of the scene, which causes the health bar's width to be set to 0 and be destroyed.
You can hack for bars
hello I have a question
if the object has more than 10 health the bar turns blue how to increase life and leave it green??
@ta_kuann instead of dividing colorHSVA by 12, divide it by (120÷maxhealth)
For example, if it has 20 health, set the colorHSVA to [_health/(120÷20),1,1,1]. Which equals [_health/6,1,1,1]
@@bouncy_foot you should also apply the same logic when coding the health bar's size and position to keep it centered
@ t’y m’y brother
The _Health is not there
@sebastianmiranda6465 I have also run into issues like this myself, try closing and reopening Algodoo and see if that helps.
_
;
'promo sm'