Forum begins after the advertisement:


[Part 10] Boss doesn’t flip

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 10] Boss doesn’t flip

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #13546
    Allan Valin
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    I think I either found a problem with the boss controller, or I just typed it wrong XD the second part of the conditions should be greater than, right?

    <code>#region health to state
            if(health > 20)
            {
                ChangeState(EnemyStates.Boss_Stage1);
            }
            if(health <= 15 && health < 10)
            {
                ChangeState(EnemyStates.Boss_Stage2);
            }
            if(health <= 10 && health < 5)
            {
                ChangeState(EnemyStates.Boss_Stage3);
            }
            if(health < 10)
            {
                ChangeState(EnemyStates.Boss_Stage4);
            }
            if(health <= 0)
            {
                Death(0);
            }
            #endregion</code>
    #13551
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Allan, you’re right. There’s been a mistake. What was intended was probably this:

    if(health > 20)
    {
        ChangeState(EnemyStates.Boss_Stage1);
    }
    if(health <= 15 && health <> 10)
    {
        ChangeState(EnemyStates.Boss_Stage2);
    }
    if(health <= 10 && health <> 5)
    {
        ChangeState(EnemyStates.Boss_Stage3);
    }
    if(health < 105)
    {
        ChangeState(EnemyStates.Boss_Stage4);
    }
    if(health <= 0)
    {
        Death(0);
    }
    #endregion

    But I will do it like that using else if structures instead so it’s more efficient (and easier to read as well):

    if(health > 20)
    {
        ChangeState(EnemyStates.Boss_Stage1);
    }
    else if(health > 15) // Gets between 15 to 20
    {
        ChangeState(EnemyStates.Boss_Stage2);
    }
    else if(health > 10) // Gets between 10 to 15
    {
        ChangeState(EnemyStates.Boss_Stage3);
    }
    else if(health > 5) // Gets between 10 to 15
    {
        ChangeState(EnemyStates.Boss_Stage4);
    }
    else
    {
        Death(0);
    }
    #13562
    Allan Valin
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    Just found out that in the BossController in AttackHandler() there’s the line int _attackChosen = Random.Range(1, 4); but with integers the upper range is exclusive, so it should be (1,5). Funny thing is, that with floats the upper range is inclusive lol In the end I couldn’t make the different phases work, and the dive attack would stuck the boss in the air with the jump animation, even when dive was set to true, or jump to false, nothing would unstuck it. So I just made it one boss, doing random attacks with whatever worked haha hitting the boss during outbreak made him fall on its head hahahah

    On the weekend I might post all my codes here for reference, there are many bugs though XD but I did solve many more that were presented in the videos lol

    #13563
    Allan Valin
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    And here is the game https://dshiryu.itch.io/ipa-quest

    #13577
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::
    Just found out that in the BossController in AttackHandler() there’s the line int _attackChosen = Random.Range(1, 4); but with integers the upper range is exclusive, so it should be (1,5). Funny thing is, that with floats the upper range is inclusive lol
    Thanks for this spot. Yup, there is actually a very good reason for this. The integer version of Random.Range() is often used to get a random item in an array, for e.g. arr[ Random.Range( 0, arr.Length ) ]. If we made the end value inclusive, then the expression will have to become arr.Length - 1.

    The reason you can’t do this for floats is because if it is exclusive, then there is no way to get a number between a and b. For example, if it was exclusive, I would have to do something like Random.Range(0, 1.001f) to get all numbers between 0 and 1, but this will include all numbers between 1 and 1.001f as well.

    In the end I couldn’t make the different phases work, and the dive attack would stuck the boss in the air with the jump animation, even when dive was set to true, or jump to false, nothing would unstuck it. So I just made it one boss, doing random attacks with whatever worked haha hitting the boss during outbreak made him fall on its head hahahah

    On the weekend I might post all my codes here for reference, there are many bugs though XD but I did solve many more that were presented in the videos lol

    We’ve started working on the revamp for the Metroidvania series. I’ll be happy to get Joseph (he’s the guy vetting the series and applying the fixes) to fix your bugs for you, but can you help me compile a list of the issues (and the corresponding part, if possible) you have for him? This will be really helpful for him because he has a large list of issues to go through.
Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: