Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in accelerateFromAngle, and add comment #1833

Merged
merged 1 commit into from
Apr 26, 2016
Merged

Fix bug in accelerateFromAngle, and add comment #1833

merged 1 commit into from
Apr 26, 2016

Conversation

16th-earl
Copy link
Contributor

(Sorry I sent the previous version of this suggestion to the wrong branch, hopefully this is ok…)

The accelerateFromAngle function has a problem in that if sine or cosine of the angle is negative, then the maximum velocity will end up being negative, which it's never supposed to be.

For example, If your current velocity was 10, and you wanted a limit of 100; depending on the angle of rotation you can suddenly end up with a maximum velocity of -100. This makes your velocity of 10 look to be 110 over the maximum. Then you get an extreme change of velocity. In the app I was working on I ended up with a constant oscillation between -100 and +100 from one frame to the next. Adding the Math.abs functions inside accelerateFromAngle, fixes this.

(Sorry I sent the previous version of this suggestion to the wrong branch, hopefully this is ok…)

The accelerateFromAngle function has a problem in that if sine or cosine of the angle is negative, then the maximum velocity will end up being negative, which it's never supposed to be.

For example, If your current velocity was 10, and you wanted a limit of 100; depending on the angle of rotation you can suddenly end up with a maximum velocity of -100. This makes your velocity of 10 look to be 110 over the maximum. Then you get an extreme change of velocity. In the app I was working on I ended up with a constant oscillation between -100 and +100 from one frame to the next. Adding the Math.abs functions inside accelerateFromAngle, fixes this.
@Gama11 Gama11 added the Bug label Apr 26, 2016
@Gama11
Copy link
Member

Gama11 commented Apr 26, 2016

Thanks!

@Gama11 Gama11 merged commit dbe883f into HaxeFlixel:dev Apr 26, 2016
Gama11 added a commit that referenced this pull request Apr 26, 2016
Aurel300 pushed a commit to larsiusprime/haxeflixel that referenced this pull request Apr 18, 2018
The accelerateFromAngle function has a problem in that if sine or cosine of the angle is negative, then the maximum velocity will end up being negative, which it's never supposed to be.

For example, If your current velocity was 10, and you wanted a limit of 100; depending on the angle of rotation you can suddenly end up with a maximum velocity of -100. This makes your velocity of 10 look to be 110 over the maximum. Then you get an extreme change of velocity. In the app I was working on I ended up with a constant oscillation between -100 and +100 from one frame to the next. Adding the Math.abs functions inside accelerateFromAngle, fixes this.
Aurel300 pushed a commit to larsiusprime/haxeflixel that referenced this pull request Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants