Player jumping to top-left in Walkabout tutorial
ffittschen opened this issue · comments
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.
I tried it out working fine on my end.