-
Notifications
You must be signed in to change notification settings - Fork 106
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
Repeat action causes small stutter #102
Comments
Great find @mattiashagstrand! 👍 How about if we always make sure that the last update that an action gets has a completion ratio of exactly 1? |
Yes, if the completion rate always becomes exactly one it should solve the problem. |
That's not really enough, since the framerate can vary in practice. What I think we need to do is to always run a final update with |
The problem isn't that we don't do an update with Here is a simplified example: Say that we want to move an actor In the first 3 updates If we had used an action to move I tested a bit more and I don't think my suggested solution works.
Was this understandable @JohnSundell? |
I created a test that demonstrates the problem: func testRepeatingActionSmoothMovement() {
let moveVector = Vector(dx: 100, dy: 0)
let moveAction = MoveAction<Actor>(vector: moveVector, duration: 1)
let actor = Actor()
actor.repeat(moveAction)
game.scene.add(actor)
game.update()
game.timeTraveler.travel(by: 0.3)
game.update()
XCTAssertEqual(actor.position.x, 30.0, accuracy: 0.001)
game.timeTraveler.travel(by: 0.6)
game.update()
XCTAssertEqual(actor.position.x, 90.0, accuracy: 0.001)
game.timeTraveler.travel(by: 0.3)
game.update()
game.update()
game.timeTraveler.travel(by: 0.3)
game.update()
XCTAssertEqual(actor.position.x, 150.0, accuracy: 0.001)
} I thought it was a bit strange that the extra
Looks like the repeat takes an extra update to start repeating. That can probably also cause stuttering. |
I have now confirmed that my fix doesn't fix anything... 😣 I tried removing the truncation of What is needed is for the extra Will stop spamming now and let you think about this @JohnSundell 😄 |
When repeating an action (e.g. rotation) each time the action repeats their is a small stutter.
This is caused by the action reset because an action rarely ends at a completion ratio of exactly one.
Changing
to
in
Action
seems to fix the problem in the case when an action is repeated but could potentially cause problems in other cases. MaybeAction
should have arestart
method? In that case the responsibility for callingreset
orrestart
probably needs to be moved out ofActionWrapper
.The text was updated successfully, but these errors were encountered: