Anyone else find that trying to generate random numbers takes up huge amounts of cpu time?

JapsterJapster Member Posts: 672
edited June 2017 in Working with GS (Mac)

I'm using random values to 'explode' tiles in a semi-random way, etc, in my latest game, and although it's okay on the device (so far), I can see that it makes my game (running in the Creator/Previewer) REALLY chuggy when a few go off!

Note, I'm literally just using:-

random(70,110)

no fancy logic, no multiple randoms, other than for each tile (2 lots of 6 tiles/actors are spawned)

I'd use particles, but they need to be influenced by gravity, and as many found out here, it's better/more manageable to make your own, so gravity is turned off in the scene. Hence, the actors have a gravity behaviour... :smile:

If I just spawn minus the randoms, it's fine, so deffo generating those that seems to cause it?

Just wondering (no access to that Android phone I'm getting yet, so can't use Android dev tools on device to confirm) if it's just a previewer issue, or actually affects the device(s) as badly in terms of high CPU usage?

Cheers guys!

Comments

  • JapsterJapster Member Posts: 672

    I suppose I'm trying to see if it's a real problem, how to use an alternative - guessing some combination of 'time', sin, cos, etc, might give similar results without the hit... :smile:

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I'm really surprised to hear this. Have you tried isolating the issue by creating a new blank scene and adding only those twelve actors? Beyond that, have you turned off all rules except the random() behaviors in that new scene?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    Using random number has never produced this issue for me personally.

    "If I just spawn minus the randoms, it's fine, so deffo generating those that seems to cause it?"

    That's not necessarily the case, it might be an interaction between two things.

  • JapsterJapster Member Posts: 672

    @Socks said:
    Using random number has never produced this issue for me personally.

    "If I just spawn minus the randoms, it's fine, so deffo generating those that seems to cause it?"

    That's not necessarily the case, it might be an interaction between two things.

    Cheers as always @Socks ! - I figured it might be because I was firing off 2 lots of 6 spawns, each randomly setting an X,Y, so 24 randoms asked for in a split second...

    But I'll look further into it to see if I can suss out the real issue!

    Cheers fella...

  • JapsterJapster Member Posts: 672

    @tatiang said:
    I'm really surprised to hear this. Have you tried isolating the issue by creating a new blank scene and adding only those twelve actors? Beyond that, have you turned off all rules except the random() behaviors in that new scene?

    @tatiang , cheers mate, at least with both you guys surprised at this, I might be barking up the wrong tree... :smiley: TBH, I turned off all rules other than that, on the actors in question, but I didn't think about other interactions - I'll take a look - I'm just glad my Mac is kind of at the limit of real-time previewing this, or I never would have noticed at the point where it happened - would have been a wasted chance at optimisation/tracing down this performance issue... :wink:

Sign In or Register to comment.