Enemies lagging your game? Here's some quick tips - GB Studio 3.1.0 Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ต.ค. 2024

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

  • @5irkarl
    @5irkarl 2 ปีที่แล้ว +4

    Another great video, thanks for the tips! I already did my own version of optimizations for the move to event (adding a move & shoot cooldown[really helps when colliding with other actors]) but this combined with the ability to toggle actors update scripts makes enjoyable topdown combat so much more feasible

  • @ELV13S
    @ELV13S 2 ปีที่แล้ว +4

    so basically optimize your scripts so its not always checking every frame, this was the "bug" thats been a feature for GALAGA. basically more actors lags the screen so by defeating enemies the game speeds up a bit then the actors speed up too as u destroy more actors the game gets harder but plays smoother XD yeah very informative

    • @linhero797
      @linhero797 2 ปีที่แล้ว +2

      While everything you said is correct, you have the wrong game. Space Invaders is the game you are describing.

    • @ELV13S
      @ELV13S 2 ปีที่แล้ว +1

      @@linhero797 oh thanks, they look similar so i musve confused the 2 xD

  • @linhero797
    @linhero797 2 ปีที่แล้ว +3

    After watching your content so much, I was thinking of making videos to show off a few things I had devloped in my time working with GB Studios. Like a Healthbar display that can use the full Signed 16 Bit Integer rather then being limited to certain amounts.
    The traditional way to Calculate percentages you would use for an HP Bar would be to multiply the Current HP by 100 and divide it by the Max HP. Due to this, the Max HP value you could use before the Variable overflowed was a bit over 320. But with this formula you can have the Max value a Signed 16 Bit Integer can hold.
    Or my implementation of a Mario and Luigi style Action Command system that I am using for my Western RPG. Or West of Loathing inspired overworld travel system, also used in my Western RPG.
    But I do not have a wonderful voice, and don't do the talking thing well, so, unfortunately I can't do much. But still, I might give it a try. The more knowledge, and the more people know how to do and what can be done, the more diverse types of genres were can experience in the games people make.

    • @RobertDoman
      @RobertDoman  2 ปีที่แล้ว +2

      You should definitely make videos! Don't worry about your voice or delivery, you will get better with time, and you can always edit out the mistakes!
      It sounds like you have a lot to share, so it would be so valuable for the community for you to share it!

    • @5irkarl
      @5irkarl 2 ปีที่แล้ว +1

      You should post a tutorial on the forums or subreddit and maybe Robert or another TH-camr will cover it, and if not the information is still out there for those willing to look

  • @linhero797
    @linhero797 2 ปีที่แล้ว +2

    One trick I think is amazing to know to help make things efficient is learning to make functions out of Mathmatics.
    Here's a story.
    Yesterday I needed to make system of checking in which 8 directions an object is from a starting point. (9 if you count an object being at the same position as the starting point)
    And when I started I used 9 If Statements. Then I optimized it to 6, then I really though about it. And realized, all I am doing is trying to find the distance between two points and turn that into an output that tells me in which of the 8 directions one point is from a starting point.
    And with that I worked on a formula and within 30 minutes I had 1, that worked perfectly for what I needed it for.
    This is a wonderful example of what I suggest everyone at least try a bit. You would be shocked the kinds of things you can make so much more efficient and cleaner with the use of Mathematics.
    Also, fuck the On Update script for Actors.
    I always used Timer Scripts attached to the Init script of the actors. Since I can set it to only update after a while, while still allowing the enemies to update decently well.

    • @5irkarl
      @5irkarl 2 ปีที่แล้ว

      I’ve seen people talk about using timer scripts for NPCs before but that never made sense to me since you’re limited to one timer script running at a time. Is there something I’m missing or have people just found an elegant solution to switch timer scripts? Currently using mine to constantly animate water so switching isn’t exactly an option although I could animate in an on update

    • @linhero797
      @linhero797 2 ปีที่แล้ว

      @@5irkarl One way to do that is to set up a list of different Timer scripts in a switch statement. And when the game needs to use a different timer, stop the current one and recall a new one based on the value entered into it.
      Also, and I may be very very wrong about this.
      I think Timer Scripts work, like Local Variables work.
      Where you can have one for each different Actor and Trigger but I could be very very wrong about that.

  • @BenJelter
    @BenJelter 2 ปีที่แล้ว +2

    I think that the reason the last version is so laggy is that the time it takes them to move from point A to point B is effectively a wait and they are reaching the destination much faster so they have to calculate positions with greater frequency.

    • @RobertDoman
      @RobertDoman  2 ปีที่แล้ว +1

      Exactly yeah, more checks per distance

  • @JWG.LLC_The_Artist
    @JWG.LLC_The_Artist ปีที่แล้ว +1

    (In the int of follower)
    Set local var check to 1
    (In the on step of the follower)
    If local var check = 1
    {Set local var check to 0
    Actor self Move to:var: player x player y
    Set local var check to 1}
    (Code only runs if following actor is not moving reducing lag)

    • @RobertDoman
      @RobertDoman  ปีที่แล้ว +2

      That is really helpful, thank you so much!

    • @JWG.LLC_The_Artist
      @JWG.LLC_The_Artist ปีที่แล้ว +2

      Just returning the favor I was watching your show pretty heavily in the beginning

  • @MarkSixbey
    @MarkSixbey 2 ปีที่แล้ว +1

    Highly helpful.

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

    If I want to make a gb color game, (I think it's color only mode) Do I need to bring a monochrome background and then make a pallet in gb studio and color the map with those pallets or can I just load a colored image?
    As long as each tile doesn't have more than 3 colors + transparency ofc.

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

      In GB Studio 4, the engine will automatically turn your coloured backgrounds into monochrome+painted tiles for you!
      And background images can be 4 colours, no transparency. That is for sprites

  • @professorplum7025
    @professorplum7025 2 ปีที่แล้ว +2

    Great tutorial. If I’m understanding things correctly a game like Asteroids would be nearly impossible without extreme lag correct? Would love a tutorial for crafting minecraft style. Like a bin you can put one piece of metal and two pieces of wood in to make an axe.

    • @RobertDoman
      @RobertDoman  2 ปีที่แล้ว +1

      I think what holds back asteroids would be the amount of actors moving to make it fun
      The more actors the worse the lag will be, but I know in asteroids they often move in straight lines, rather than update their movements every frame, so that might mean it's possible, but would have to be tested to be sure.

    • @linhero797
      @linhero797 2 ปีที่แล้ว +2

      By Minecraft style, you mean a Minecraft Style crafting system? Because if that's the case I have an idea for how it might be implemented but I would need to experiment with it myself to confirm.

    • @5irkarl
      @5irkarl 2 ปีที่แล้ว +2

      The Minecraft thing is entirely possible and I have it mostly setup, there’s two ways to go about it though. You can either have the crafting table switch to a new scene where you can visually craft like in minecraft bedrocks crafting menu, or you can store the players equipped item value in the crafting bench actor and make so it when a recipe is completed you get the item. The second scenario is currently limited to 2 ingredients but I’m sure with a little math you could get the full Minecraft 9 easy

    • @RobertDoman
      @RobertDoman  2 ปีที่แล้ว +2

      @@5irkarl I would say the thing that makes the minecraft crafting difficult in GB Studio would be the 9 slots like you said, and the sheer amount of things you can craft. Otherwise it is technically very simple haha. Always start small. Figure out what your game needs and it is probably possible.

    • @5irkarl
      @5irkarl 2 ปีที่แล้ว +1

      @@RobertDoman yep I’ve been on my test island for like 2 months perfecting controls and buildings/items/spawning. Currently limiting myself to 24 items and 1 npc but with the recent update and this video I might be able to make buildings and NPCs interchangeable combining their limit to 9(previously 7 buildings +1 spawner +1 NPC) maybe more I havent tested a big scene yet as during my previous limit testing actors didn’t update offscreen

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

    interesting, move by tiles is actually less expensive than move by pixel.

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

    For some reason they are all moving the same direction in unison, I believe I did something wrong

  • @alexbale1418
    @alexbale1418 2 ปีที่แล้ว +1

    Can you think of a way to get "OnMove" so that NPC's following only move when you do? I'm sure that would save alot of processing time instead of just making them move to the exact same spot every frame.

    • @RobertDoman
      @RobertDoman  2 ปีที่แล้ว

      Possibly, using the 'if joypad held' event, but it'll still be checking every frame unfortunately, but it might be worth a try

    • @alexbale1418
      @alexbale1418 2 ปีที่แล้ว +1

      @@RobertDoman The changes in 3.0+ To triggers stop your old tutorials about random encounters from being able to work. Was hoping for an easy way to get a random encounter only when the player moved instead of onUpdate.

    • @RobertDoman
      @RobertDoman  2 ปีที่แล้ว

      @@alexbale1418 yeah that is a huge shame, I can't think of alternate solution right now though

  • @bubbles8990
    @bubbles8990 ปีที่แล้ว +1

    for some reason my game always lags for a second or so whenever i use the actor relative to actor script and the player enters the boundaries. Is there any way to fix this?

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

      It will always feel like that because you are suddenly increasing the amount of work the GameBoy is doing every frame
      You can use the techniques in this video to help improve it, or you can have them set to still work while off screen so there isn't a change when the player enters the boundaries

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

    What is that "MOVE LEFT" Script in the Event menu? I can't find it.

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

      Do you have a timestamp?
      I often simply rename groups or scripts to help make it make more sense when reading over it quickly

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

      @@RobertDoman 3:03

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

      @@impossiblestudios77 yes that is just a way of organising the code, it is just an event group renames to say move left

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

      @@RobertDoman oh thank you.

  • @CatSpaceStudio
    @CatSpaceStudio ปีที่แล้ว +1

    Having two actors with collision on is super laggy. But when I take collision off it runs perfect. The only issue, when I try to do it the way it’s shown in the video they don’t move at all? Still not sure what’s up here or how this is happening. Lol

    • @RobertDoman
      @RobertDoman  ปีที่แล้ว +1

      I recommend testing it in a blank scene of even a new project so you can test it properly yourself. Depending on what you want for your game, you may have to make sacrifices unfortunately.
      I wouldn't be able to tell you what is wrong without looking at it. Just make sure your variables are referenced correctly and you can logically understand each step in the events.

    • @CatSpaceStudio
      @CatSpaceStudio ปีที่แล้ว +1

      Man I feel stupid. I sat down and really thought about it and figured it out pretty quickly actually. Also the 8 way movement (adventure) brings all of this down so so much. When I finally switched it back to 4 way movement it almost fixed it all. Thanks again for the quick replies! Hopefully I won’t be making dumb mistakes going forward. Lol

    • @RobertDoman
      @RobertDoman  ปีที่แล้ว +1

      @@CatSpaceStudio no problem at all, I'm glad you figured it out!

    • @CatSpaceStudio
      @CatSpaceStudio ปีที่แล้ว +1

      @@RobertDomanI think this is the last question I have regarding ai, now on collision and sometimes just randomly my entire sprite will disappear for a second. Any way this can be fixed or advice on what is causing this?

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

      @@CatSpaceStudio it sounds like you may have a frame missing in your sprite editor
      Definitely check your walking animations to make sure there isn't a blank frame!

  • @CatSpaceStudio
    @CatSpaceStudio ปีที่แล้ว +1

    I managed to get almost everything solved and have learned a lot. But when making a health ui much like your other video, having two enemies on screen “chasing” the player is bogging the game down a lot. And that’s without any attack scripts assigned to the enemies. Any advice there?

    • @RobertDoman
      @RobertDoman  ปีที่แล้ว +1

      This video is about enemies lagging the game, but basically you need to do the testing to see what impacts it the most and what you need in your game Vs what slows it down

    • @CatSpaceStudio
      @CatSpaceStudio ปีที่แล้ว +1

      @@RobertDomanyeah I watched this one a few times and also messed around with a few other options. Can’t seem to find much online about ui and enemies at the same time. And sadly I will need both. Just not sure how to have a ui and enemy movement without massive lag as a whole. Is there a way to put health ui to “on int” instead of update?

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

      Definitely, put it so when you get hit, it changes its state, rather than on update

    • @CatSpaceStudio
      @CatSpaceStudio ปีที่แล้ว +1

      @@RobertDoman how exactly would that work? Because when I try to script it then it acts on entry to the scene usually. I can’t seem to properly get player health ui to change accordingly with “on int”

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

      On initiate means when the scene starts.
      If you are are working with the player health, then you should use On Player Hit for example. That way you can make actions happen only when the player would take damage