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: 1033
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.
RIP Pirate Wray
April 2002-September 2018

merrak

  • *
  • Posts: 2202
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: 1808
Remove the collision shapes from your coins and see if the problem persists.
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

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: 1808
The shapes are still being drawn though. Did you try removing them?
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

ozz

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

JeffreyDriver

  • Posts: 1808
I'm trying to help you troubleshoot the problem. Check if that's the issue then we can create a solution.
Current Projects:
Retro Redux Compilation (NEW).
Retro Redux (untitled) (NEW).
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

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: 2259
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.