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

Player jumping to top-left in Walkabout tutorial #172

Open
ffittschen opened this issue Mar 26, 2018 · 1 comment
Open

Player jumping to top-left in Walkabout tutorial #172

ffittschen opened this issue Mar 26, 2018 · 1 comment

Comments

@ffittschen
Copy link

Hi!

I just tried gave ImagineEngine a try and followed the Walkabout tutorial. Somehow I'm seeing weird behavior, when I click on a horizontal axis right of the player (see attached gif). Sometimes, the player just jumps to the top-left corner of the scene.

To be sure that this isn't a bug caused by me, I copied the content of FinalCode.swift and it still happens.

Afterwards I modified the code to print some stuff:

events.clicked.observe { _, point in
+   print("click: \(point)")
    moveToken?.cancel()

    let speed: Metric = 100
    let horizontalTarget = Point(x: point.x, y: player.position.y)
    let horizontalDuration = TimeInterval(abs(player.position.x - point.x) / speed)
    let verticalTarget = Point(x: point.x, y: point.y)
    let verticalDuration = TimeInterval(abs(player.position.y - point.y) / speed)

    moveToken = player.move(to: horizontalTarget, duration: horizontalDuration)
        .then(player.move(to: verticalTarget, duration: verticalDuration))
        .then(player.playAnimation(idleAnimation))
+       .then { print("horizontalTarget: \(horizontalTarget), verticalTarget: \(verticalTarget), player.position: \(player.position)") }
}

This are the print statements when the bug occured:

click: (268.0, 309.0)
horizontalTarget: (268.0, 384.0), verticalTarget: (268.0, 309.0), player.position: (268.0, 309.0)
click: (387.0, 309.5)
horizontalTarget: (387.0, 309.0), verticalTarget: (387.0, 309.5), player.position: (387.0, 309.5)
click: (506.0, 309.5)
horizontalTarget: (506.0, 309.5), verticalTarget: (506.0, 309.5), player.position: (16.0, 23.0)

Somehow the position of the player is (16.0, 23.0) when it should be (506.0, 309.5) 🤔
Its quite easy to reproduce by clicking top-left of the player and then twice on the right side of the player as in the gif and seen in the logs.

player_jumping_top_left

@Aviral190694
Copy link

I tried it out working fine on my end.

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

No branches or pull requests

2 participants