Algodoo tutorial: Health bar

Поделиться
HTML-код
  • Опубликовано: 10 янв 2025

Комментарии • 30

  • @CyanBeast01
    @CyanBeast01 Год назад +6

    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
    :)

  • @liBlanca-ii7ve
    @liBlanca-ii7ve Год назад +1

    tysm!! i learned how to make a tuna fish game with this method! ps i subbed!

  • @liBlanca-ii7ve
    @liBlanca-ii7ve Год назад

    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

  • @vuongnguyenminh4368
    @vuongnguyenminh4368 Год назад

    Bro this guy deserve more subcribe then this!

  • @IrwinEthanRotil300
    @IrwinEthanRotil300 7 месяцев назад

    Thanks for the tutorial brother

  • @DiscoverWalkingTours
    @DiscoverWalkingTours 3 месяца назад

    I want to learn this marble stuff but it;s too difficult

  • @zenaidemotta1674
    @zenaidemotta1674 3 месяца назад

    Thank you

  • @playthowhin
    @playthowhin 4 месяца назад

    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

  • @playthowhin
    @playthowhin 4 месяца назад

    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...

    • @leolimarblerace4391
      @leolimarblerace4391  4 месяца назад

      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

    • @leolimarblerace4391
      @leolimarblerace4391  4 месяца назад

      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.

  • @Namsterste
    @Namsterste 10 месяцев назад

    Thanks for tutorial
    Nice tutorial

  • @Lilacmymy7
    @Lilacmymy7 7 месяцев назад

    You can hack for bars

  • @bouncy_foot
    @bouncy_foot 2 месяца назад

    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??

    • @leolimarblerace4391
      @leolimarblerace4391  2 месяца назад

      @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]

    • @leolimarblerace4391
      @leolimarblerace4391  2 месяца назад

      @@bouncy_foot you should also apply the same logic when coding the health bar's size and position to keep it centered

    • @bouncy_foot
      @bouncy_foot 2 месяца назад

      @ t’y m’y brother

  • @sebastianmiranda6465
    @sebastianmiranda6465 5 месяцев назад

    The _Health is not there

    • @leolimarblerace4391
      @leolimarblerace4391  5 месяцев назад

      @sebastianmiranda6465 I have also run into issues like this myself, try closing and reopening Algodoo and see if that helps.

  • @davidulisescarreonyee5619
    @davidulisescarreonyee5619 Год назад

    _

  • @wilbertsohrweide9405
    @wilbertsohrweide9405 Год назад

    'promo sm'

  • @davidulisescarreonyee5619
    @davidulisescarreonyee5619 Год назад

    ;