Custom speed acting weird

Bugs will be moved here once resolved.

Post » Fri Oct 23, 2015 5:46 am

Problem Description
custom movement behavior gets stuck at 200.00000000000003

Attach a Capx
Project

Description of Capx
this cap shows you the overall speed of the arrow

Steps to Reproduce Bug
  • Step 1 turn player to a diagonal angle
  • Step 2 accelerate player to maximum speed
  • Step 3 when player reaches maximum speed turn around and try to accelerate another way

Observed Result
the speed seems to get stuck 200.00000000000003 even though I clearly set it back to 200

Expected Result
when it reaches higher then maximum speed it should reset back to 200 allowing the player to move again

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

Operating System and Service Pack
Windows 10

Construct 2 Version ID
212.2 and beta r214
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Sat Oct 31, 2015 11:13 pm

Hey Shadow, the problem with it is that in event 2 in your movement sheet is asking if the speed is not only less than but also equal to. So you can be at the max speed and that accelerate will still be trigger-able. I know that the event below should set it back to 200 (but there really is not much difference between 200 and 200.00000000000003).

In event 4, switch the else action to set speed to 199 instead of 200 and it works as intended (it just doesn't look pretty).
ImageImage
B
112
S
23
G
7
Posts: 1,064
Reputation: 12,787

Post » Thu Nov 12, 2015 12:26 pm

Closing as not a bug: as @GenkiGenga says, you allow acceleration when the speed is exactly equal to 200, allowing it to accelerate slightly beyond. Even with that though, you should not expect the speed to exactly equal 200. See "Expecting math calculations to be exact" in common mis-used events and gotchas.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests