Algodoo tutorial: Health bar

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

ความคิดเห็น •

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

    • @LighterRacer1634
      @LighterRacer1634 11 หลายเดือนก่อน

      how are you so good at scripting?

    • @CyanBeast01
      @CyanBeast01 11 หลายเดือนก่อน +1

      ...

    • @LighterRacer1634
      @LighterRacer1634 11 หลายเดือนก่อน

      @@CyanBeast01 uhm

    • @Lilacmymy7
      @Lilacmymy7 7 หลายเดือนก่อน

      Perfect script

    • @EJSJ16
      @EJSJ16 5 หลายเดือนก่อน

      Imma sub on him cuz why not?

  • @zenaidemotta1674
    @zenaidemotta1674 2 หลายเดือนก่อน

    Thank you

  • @liBlanca-ii7ve
    @liBlanca-ii7ve ปีที่แล้ว +1

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

  • @IrwinEthanRotil300
    @IrwinEthanRotil300 7 หลายเดือนก่อน

    Thanks for the tutorial brother

  • @vuongnguyenminh4368
    @vuongnguyenminh4368 ปีที่แล้ว

    Bro this guy deserve more subcribe then this!

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

  • @Namsterste
    @Namsterste 10 หลายเดือนก่อน

    Thanks for tutorial
    Nice tutorial

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

  • @DiscoverWalkingTours
    @DiscoverWalkingTours 3 หลายเดือนก่อน

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

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

  • @Lilacmymy7
    @Lilacmymy7 7 หลายเดือนก่อน

    You can hack for bars

  • @bouncy_foot
    @bouncy_foot หลายเดือนก่อน

    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  หลายเดือนก่อน

      @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  หลายเดือนก่อน

      @@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 หลายเดือนก่อน

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

  • @wilbertsohrweide9405
    @wilbertsohrweide9405 ปีที่แล้ว

    'promo sm'

  • @davidulisescarreonyee5619
    @davidulisescarreonyee5619 ปีที่แล้ว

    _

  • @davidulisescarreonyee5619
    @davidulisescarreonyee5619 ปีที่แล้ว

    ;