"For Each" Causing Problems

Bugs will be moved here once resolved.

Post » Sun Jan 03, 2016 6:03 pm

Problem Description
I'm trying to control a physics sprite with a gamepad. I reached a point where I started working on an entirely different part of the game, and suddenly problems, where everything was previously working perfectly, started popping up! If seemingly any "For Each" event was used in combination with my code to change the angle of the physics sprite, the sprite will always try to aim to the right or 0 degrees. It's meant to still remain in the general direction it was facing... not return to 0 degrees.

If I disable the "For Each" code, it works as intended. I thought it was because my original "For Each" contained the player sprite, so I changed it so it was completely disconnected, and the same error occurred. Tried on multiple devices running 216.

Attach a Capx
https://copy.com/puXdKs9PCtrA0Orr

Description of Capx
Capx shows a very simple game producing the problem I'm having.

Steps to Reproduce Bug
  • Play Game with GamePad connected
  • Touch a button and move the right stick
  • Note that the player sprite will rotate, but always return to 0 degrees when you release the stick
  • Close the game, disable the "For Each" event(s), and play the game again
  • Note that the player sprite will rotate and will not try to aim back to 0 degrees when the stick is released

Observed Result
The Player sprite will always try to aim towards 0 degrees

Expected Result
The Player sprite should remain towards it's last angle, or spin

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Internet Explorer: (YES)

Operating System and Service Pack
Windows 7 and Windows 10

Construct 2 Version ID
Release 216
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Sun Jan 03, 2016 8:06 pm

I don't have a joystick, but I can't get the same result if I use keyboard instead. What are the values returned for the joystick axis when not pressing anything?
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Sun Jan 03, 2016 11:19 pm

@R0J0hound If the "For Each" is on, when the joystick is released, it reverts back to 0. Then again, the GamePad object doesn't have any values, so I had to gain that info by setting a variable to:

angle(0,0,Gamepad.Axis(0,2),Gamepad.Axis(0,3))

as I'm dealing with the right stick. Just did a quick test, however, and it appears to work fine for the left stick. Doesn't help me though, as I'll be using both sticks.

Also tried this with the latest beta, and it's still a problem.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Tue Jan 05, 2016 12:46 am

Sounds like it may be an issue with the gamepad plugin perhaps. The issue of the "for each" effecting the other events possibly could be related to an "or" bug reported about a week ago.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Tue Jan 05, 2016 3:52 am

;) You are using "loopindex" in the "Gamepad loopindex Right analog axis" action! "For each" is changing loopindex, so it is changing the Gamepad index unintentionally.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Thu Jan 07, 2016 7:38 am

@blackhornet Ahh... is this a bug then? I use loopindex to base it off of the number of gamepads... I wanted to save myself repeating the code 4 times.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Thu Jan 07, 2016 2:33 pm

If you give your loop a name, loopindex("gamepad"), it will work fine.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Fri Jan 08, 2016 6:17 am

@blackhornet Thanks a lot ☺
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Fri Jan 08, 2016 1:26 pm

It's not valid to use loopindex outside of a loop, so closing as not a bug. As it is, you'll be using whatever loopindex value was left behind by the last loop.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 7 guests