Function Call causes sprites to move twice as fast

Bugs will be moved here once resolved.

Post » Sun Sep 08, 2013 4:11 pm

Link to .capx file (required!):
https://www.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
B
8
S
3
G
1
Posts: 34
Reputation: 1,395

Post » Sun Sep 08, 2013 10:58 pm

Link to .cap file
Here is a more compact file...

https://www.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
B
8
S
3
G
1
Posts: 34
Reputation: 1,395

Post » Mon Sep 09, 2013 11:55 am

Can you reproduce in r143?
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Mon Sep 09, 2013 1:19 pm

@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.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Mon Sep 09, 2013 2:31 pm

@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.
B
8
S
3
G
1
Posts: 34
Reputation: 1,395

Post » Mon Sep 09, 2013 3:04 pm

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.zenox982013-09-09 15:06:19
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Mon Sep 09, 2013 4:51 pm

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:



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

B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Tue Sep 10, 2013 12:09 am

@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.
B
8
S
3
G
1
Posts: 34
Reputation: 1,395

Post » Tue Sep 10, 2013 2:36 pm

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.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests