dop2000's Forum Posts

  • I don't know your game, so I don't understand what's going on in that gif..

    Did you try the things I suggested in my previous comment? If you draw something else on the canvas, can you see the canvas object?

  • Because Repeat calls the function every tick, if I understand correctly, and the loops overlap each other.

    Yes, any condition runs on every tick, unless you put it inside some triggered event or a function.

    I assumed you would use my code inside "Enemy on created" event or something like that.

    The code in your last screenshot is too complicated and possibly buggy, especially with multiple enemies.. You should either create all waypoints for the full path in one go, or use "On arrived" trigger to move to the next point. I also suggest using Timer behavior instead of "Every x seconds" and "Waits" - it gives you much more control and you can run different timers for each enemy instance.

    For example, if you you need an enemy to move to point A, wait 1 second, move to point B, wait 3 seconds, then you should use this sequence of events (in pseudocode):

    On created: Move to A
    On arrived to A: Start timer "moveToB" for 1 second
    On Timer "moveToB": Move to B
    On arrived to B: Start timer "patrol" for 3 second
    
  • I can agree with #1 and to some extend with #2, but #3 is definitely unrealistic and will not be compatible with the current expression structure.

    I would suggest posting 3 different ideas, to allow people voting for each idea separately. Ashley has repeatedly asked not to put multiple suggestions in a single post.

    • Post link icon

    XHXIAIEIN Large images - no, large layouts - yes. But I don't see how this can explain the random nature of the problem. I can be working with events for an hour without any lags, and it would suddenly freeze for 20 seconds when I enter a new action or edit a comment.

    1StepCloser I can try, but my other laptop is very old and low spec. It will probably be just constantly slow.

    Asmodean Thanks, I didn't know about the task manager in Chrome. It doesn't show anything useful though. During the freezes the CPU value for Construct 3 tab jumps to 100-150. But nothing else changes.

    Windows Task manager only shows a small increase in CPU usage for Chrome - from ~3% to 6-7%. There are no spikes for other apps or services.

    Jase00 I managed to force Chrome to use my Nvidia GPU. The editor did feel a bit faster overall. But it didn't fix the occasional freezes unfortunately.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Never use "Trigger once" with multiple object instances, it will not work correctly! If you want to execute some code for an Enemy instance once, you should use state variables, for example create isReloading instance variable.

    There is another issue - once you picked an enemy with no ammo, you can't pick another instance (its teammate) in the same event. A common solution is to use a family. Add Enemy sprite to EnemiesFamily and then you should be able to do something like this:

    Enemy Ammo<=0
    Enemy isReloading=0
    . EnemiesFamily Pick nearest to (Enemy.X, Enemy.Y)
    .. Enemy Set isReloading to 1
    .. Enemy Pathfinding Stop
    .. Enemy Find path to (EnemiesFamily.X, EnemiesFamily.Y) 
    

    I also recommend running this code in the same event where the enemy fires a bullet. This way you will be saving resources because it will not be running on every tick, and it will only execute for a single enemy instance.

    When reloading is finished, set isReloading to 0.

    There may be other complications. For example you probably don't want two enemies with no ammo to run to each other. So you might need to move isReloading instance variable to the family level. And when picking a teammate check that it's not reloading.

    Also, the available teammate may be too far away, or there may not be a clear path to it - you should consider these things too in your code.

  • So when you set to wait 4 seconds before deleting the sprite - was the sprite visible for 4 second? Then disappeared, but there was nothing on canvas?

    Can you try drawing something on the canvas before pasting? For example fill it with red color, draw a blue circle. Then paste the sprite, wait a few seconds, move the sprite 100px to the side.

    This way you would at least know if the pasting action doesn't work, or if the issue is with something else. Perhaps the canvas is not created, or it's invisible or it's in a different place, or the size is wrong etc.

    Oh, and also add "Wait 0" before pasting, maybe this will help.

  • With MoveTo you can do something like this:

    Repeat 10 times
     Sprite MoveTo position (startX, startY+loopindex*100) (add waypoint)
     Sprite MoveTo position (startX+50, startY+loopindex*100+50) (add waypoint)
    

    In your screenshot you left tween tags empty "". Just give them descriptive tags like "move_left", "new_cycle" etc. Then you will be able to track the progress of every tween using events like "Tween is playing", "Tween finished".

  • You can test in an old C3 version - if it still works there and doesn't work in the latest version, then it may be a bug, and you can report it.

    I know pasting on Canvas was working in my Android game, but I haven't updated it in almost two years.

    • Post link icon

    Thanks. In my case the laptop is always plugged in. And the power management profile is always set to "High performance".

    • Post link icon

    what if the temperature of your integrated graphics is getting too high and throttling itself, but other apps on your computer are using the dedicated Nvidia GPU which means other apps wouldn't freeze at all?

    dGPU on this laptop is only enabled when gaming. All other apps are using integrated graphics. There is an icon in windows tray that shows when a program is using dGPU, so I'm sure about this.

    Yeah, I also tried to force Chrome to use dGPU in the past, but didn't have any luck.

    The temps are low when I'm working in C3, I've checked them many times. But to test your theory, next time the editor starts to lag I'll put a large ice pack under the laptop, see if it helps :)

    • Post link icon

    XHXIAIEIN Nvidia GPU is disabled when I'm working in Construct. It uses the integrated Radeon graphics.

    Regarding some problem with the power - I guess this may be possible, but it would probably affect all apps. Like I said, other apps are not affected by these freezes.

    1StepCloser Thanks for posting that bug report!

    I haven't tried the latest beta yet. I expect it will probably make the freezes shorter, but won't fix them completely, because something else (not autocomplete) is causing these lags in my case.

    Yesterday my Chrome was lagging almost non-stop for about half an hour. Even opening the project was taking 3-5 minutes instead of the usual 10-20 seconds. And today there were barely any lags. This randomness is driving me crazy!

    Asmodean I tried your suggestions. Chrome with disabled hardware acceleration - still freezes. Edge - same thing. So it must be something specific to the Chromium engine.

    Firefox - no freezes, but it's just generally quite slow. My game runs at 100 fps in Chrome, but only at 30-40 fps in Firefox.

  • Another option is to keep using instance variables on the Player sprite, but make the Player sprite global.

    The global instance of the Player sprite will automatically move to another layout with all its instance variables. All you need to do is set its position and maybe move to the correct layer.

    You need to be very careful - keep only one copy of the Player in the project (put it on the first layout), don't create new instances and don't destroy it. It's very easy to make a mistake and end up with multiple instances of the object, which will cause all kinds of bugs. That's why I don't recommend this method.

  • You don't have to transform all instance variables to global. Only those which need to be preserved when switching layouts.

    Working with Dictionary is easy and not much different from global variables.

    You can give any names to dictionary keys. For example:

    Dictionary set "lives" to 5

    Dictionary set "score" to (self.get("score")+100)

    Dictionary Compare "lives" value=0 : Player play animation "death"

    etc.

    There are probably some tutorials and lessons on how to use dictionaries, try googling.

  • Most common method is to use global variables for values which you need to be available across multiple layouts. You can also use dictionaries, arrays, JSONs.