Function Call causes sprites to move twice as fast

0 favourites
  • 9 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • Link to .capx file (required!):

    dropbox.com/s/bz6t7dotl65jtgq/bug_OnParticleCreation.capx

    Steps to reproduce:

    Fly the ship around for approx 20-30 seconds and you will see that some missiles move faster than others

    Trigger:

    Events Sheet: EvadeMain

    Group: Main - Collisions Section

    When the particle explosion is created via a function some missiles end up moving faster than they should

    When the particle explosion is created directly in the collision code the bug isn't present

    Observed result:

    Odd missiles move at double speed

    Expected result:

    All missiles should move at the same speed

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Operating system & service pack:

    Windows 7 Professional

    Construct 2 version:

    Release 139 (64-bit/Steam)

    Notes:

    Although this test uses lots of spawned enemies and missiles to ensure the bug shows up, it also appeared during level testing when I had only 10 or so enemies and perhaps 20-30 missiles.

    The bug was also present in other tests when the missiles used the Bullet Behavior / Move Forward command / direct Sin,Cos calculations.

    Using some quick calculations on other tests I found the bugged missiles moved at exactly double the speed they are set to.

    Please forgive the slightly larger code, I have spent five days tracking down this bug, from dissecting my game to creating small tests. In the end I started building my game from ground up slowing adding pieces until finally the bug appeared again.

    I will try and create a more compact test later next week

    Cheers

  • Link to .cap file

    Here is a more compact file...

    dropbox.com/s/mq2a14cm54ewhmi/bug_OnParticleCreation_Compact.capx

    While I was reducing the code down the bug went away when everything was on one event sheet. I thought that perhaps the bug was caused by calling the explosion function from another event sheet...

    However it seems simply including an empty event sheet makes the bug appear

    • > If I include the empty event sheet the bug appears
    • > If I remove the include to the event sheet the bug disappears

    This has left me very puzzled

    Browser Effected:

    Firefox: yes

    Chrome: yes

  • Can you reproduce in r143?

  • Ashley

    I'm using the latest r143 and can confirm the behavior.

    If you just run his 2nd .capx and watch, you'll see some bullets move a lot quicker than the rest.

    Delete the empty include - EventTest - and re-run. It appears that all bullets move at a constant speed now.

  • zenox98

    Glad that you can confirm the behavior.

    This being my first project in Construct 2 and still learning the setup and calling functions etc, I went through rewrote, shuffled events so many times to ensure it wasn't my code.

    Naturally I only used one event sheet when I started bug testing, so I did feel I was starting to lose the plot when I couldn't reproduce the bug.

  • It could be calculation error from the missile_Update function when fps drops too low, which on my PC, is around 44 FPS for this, which considering what's going on seems far too low IMO.

    Is there a reason why you haven't used the Bullet behavior? It may be less of an FPS hog than manually calculating updates for the missiles.

  • I put a boolean flag on the missile to see if it's trying to move twice in the same tick and sure enough it is:

    <img src="https://dl.dropboxusercontent.com/u/8367729/construct/pics/foreachtwice1.PNG" border="0" />

    Then I printed out the IID and UID of each missile in the 'for each missile' loop and got this:

    <img src="https://dl.dropboxusercontent.com/u/8367729/construct/pics/foreachtwice.PNG" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • zenox98

    Originally the missiles did use the Bullet behavior however the bug was still present. I changed the code to use Move Forward to ensure it wasn't related to the Bullet Behavior.

    I didn't come across any problems with the fps, during the game there are only a maximum of 20-25 enemies and 40-50 missiles at peak times also each missile has a short 5 second life span, so nothing close to the test files I uploaded.

    I've only been using Construct 2 for 4 weeks so still not 100% sure what to expect in regards to Construct 2 speed capabilities and which routines are quickest. Now that I am a little closer to understanding what is causing the errors I'll probably revert back to using the Bullet Behavior.

    ramones

    That is an interesting result as I felt there had to be a double call somewhere. As I mentioned above the bug was present when I had the missiles controlled by the Bullet Behavior which is still odd.

    I guess there could have been a problem during the For Each missile loop as well, however I doubt I would have spotted it as it was only used to control the turning and lifetime.

    Cheers all

    I hoping that in the short term if I use a single event sheet for the game that will cure the problem.

  • I can't reproduce any issue in my dev copy of r144. All missiles appear to move at exactly the same speed. Perhaps it's a bug we've already fixed.

    Closing for now - if you can still reproduce with r144 when it's out, re-submit it again. It would also be helpful as per the guidelines to make a minimal example, only including objects and events directly relating to the bug, and also demonstrating the bug immediately if possible.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)