Stencyl 3.4.0 is now out. Get it now!

Random Integer Causing Lag (coin explosion)

ozz

  • *
  • Posts: 459
I got a bit of code(I included it in an image) the makes coins fly randomly from defeated enemies in exactly the way I wanted, but when there are a few dozen coins created it can slow the game down for a second.  Is there any what to get the same effect without the slowdown when a large number are created?

NickamonPoppytail

  • *
  • Posts: 471
It may not be the random number generation slowing your game down, but the coins. Too many actors colliding can really slow down a Stencyl game.

merrak

  • *
  • Posts: 1636
Generating big numbers doesn't cause lag in of itself. The problem is going to be something else... probably coin-coin collision detection.

JeffreyDriver

  • Posts: 1306
Remove the collision shapes from your coins and see if the problem persists.

ozz

  • *
  • Posts: 459
Thing is that Actor Group they belong to can not interact/collide with themselves or other actors save for tiles and the player, but it only lags when they are first created.

« Last Edit: December 03, 2017, 01:32:05 pm by ozz »

JeffreyDriver

  • Posts: 1306
The shapes are still being drawn though. Did you try removing them?

ozz

  • *
  • Posts: 459
Well without the hit box it wouldn't work anymore.

JeffreyDriver

  • Posts: 1306
I'm trying to help you troubleshoot the problem. Check if that's the issue then we can create a solution.

ozz

  • *
  • Posts: 459
Sorry,  I've done that, it didn't seem to matter, though I did notice chests dropping lots of money doesn't cause any lag.  I think it may have more to do with the actor doing the dropping.

TheIndieStation

  • *
  • Posts: 2200
Is there another behavior that does a loop for each of those coins?

ozz

  • *
  • Posts: 459
Not actually, they are farly simple past the creation.  That said I have been doing further tests and the lag seems at it's worst when the player drops their coins.  These does involve some random values and active hit boxes so I've been testing both in the hopes of isolating the issue.  No luck just yet.