Closed Pattentrick closed 11 years ago
Easy answers first:
temporaryInvulnerabilityAlpha: 1
to ignore the visual effect (immunity is still applied).updateCurrentAnim
that automatically sets animations based on the state and facing of the character. So your character does start with the animation "idleDown", but update comes before draw so the animation is switched to whatever the facing direction is (usually to the right by default) before the first draw happens. If you want your character to start with the down animation, you'll need to set the initial facing.x/y
to 0 and 1 respectively.As for the main issue, it looks like as your character is walking the path it is making slight adjustments to the left and right. To make a movement in any direction, a character calls the "move" + direction method, and these set the facing.x/y
property accordingly. I changed the pathfinding recently to move from the corners of an entity, instead of always from the center, to improve the accuracy of the pathfinding. It looks like this change also made the facing property less stable... maybe. It is also possible that the facing is changing slightly every time a new path is found. I think it may be the latter option, but I need to test it.
A possible easy fix on your end would be to override all the "move" + direction methods to threshold the facing change. In other words, an entity can change their facing direction if (a) they currently are not moving yet this.moving === false
, or (b) they must have been moving in that direction for a set number of frames.
@collinhover Thank you for your answer and explaining me how the temporaryInvulnerabilityAlpha
and updateCurrentAnim
works! For now i will try to override the move methods to work around my main issue.
I modified the "move" + direction methods to fix the facing issue. However the animation on moving down, when using pathfinding, is still broken.
It seems like that the moveLeft and moveRight methods get called repeatedly on moving down. After those calls my „idleDown-animation“ gets executed everytime, and my „moveDown-animation“ gets interrupted again.
So on moving down, my player shows his „moveDown-animation“ for a split second, then for few moments my „idleDown-animation“, after that my „moveDown-animation“ again ... and so forth.
I made a short video to showcase this behavior
http://www.youtube.com/watch?v=ACddVSCrKWg
If you look closely, sometimes the player seems to „float“. The „float moments“ are actually my „idleDown-animation“. I also updatet the demo code:
https://github.com/Pattentrick/pathfinding-bug-demo
Fun fact: This bug only occurs on moving down! Moving in all other directions works as expected, although the "move" + direction methods are getting called there too, when walking on a straight line.
Okay, so it looks like there are actually 2 issues:
moveLeft/Right
are being called occasionally, causing short flickering of animation to left and right.idle
animation for short periods while moving.Is this a good summary?
A good summary indeed! What confuses me the most about this issue, is that it just seems to affect the down movement.
Small update: I've got some rather large changes internally that I need to double check for stability, then I'll dive into this fix.
I noticed in your player you override the moveToLeft/Right
methods to only allow a facing change when the character is already moving. What exactly did this fix for you?
This fixed the strange facing behavior of the player on moving down, which you can see on this video:
Oops, this was a silly bug. A minor change to fix some issues with entities sticking to slopes in side scrolling mode was causing the movingY
property to be set to false in most cases of top-down mode. The move animation requires that the character be moving
, and that property is just a combination of movingX || movingY
. However, neither was true, so the idle animation was playing.
I'll be pushing this shortly and I'll include your fix to disable facing change unless the character is moving. There will be a lot of changes in this push, but I dropped the latest version into your demo and it seemed to work without changing anything. On a side note, you might consider adding a small trap to your camera (see ig.Camera.boundsTrap
). Pathfinding left and right in top down mode seems to have very slight vertical shifts, which I'm looking into now.
I noticed in your user config you have the pathfinding delay set to 0, which means your characters are going to try to find a new path every frame, and this is rather expensive. However, the pathfinding delay is behaving incorrectly, in that if the character has no path it should not delay finding a new path, so I'll fix that and include it with the upcoming push.
You can remove PATHFINDING_DELAY:0
from your user config, as the pathfinding delay is now reset when the character starts moving to another entity or point. This means the character will find a path and start moving instantly instead of having random delays.
As mentioned above, you can remove your moveTo
+ direction overrides, I've included those changes in the the library (thanks for trying them).
Sounds great, can't wait to get my hands on the fixed version! Thank you for your effort on this one and fixing all the issues. And thank you for including my changes in the library. That makes me actually very proud ;-)
I do like impact++ very much, keep up the good work!
Everything should be much smoother and working as expected.
Hi there,
now back to my favorite topic: pathfinding! I switched to impact++ r6dev, because r6 fixed a bug of mine mentioned in Issue#99. Now i think i have found another bug related to animations and pathfinding.
When my player is moving down in a straight line, for a very short moment the „down-animation“ gets interrupted by my „moveX-animation“, causing the „down-animation“ to start all over again.
Switching on debugmode reveals that the path points for a split second to the right or left. And at this moment my „moveX-animation“ shows up. The strange part is that this only occurs on a down movement. Animations in all other directions are working as expected.
I made a video about this behavior:
https://www.youtube.com/watch?v=GItt0ky80hA
I also made a demo (i am using impact 1.23 there):
https://github.com/Pattentrick/pathfinding-bug-demo
And here is my player class in case i messed up something:
Another thing i noticed is that the animInit is not working on my player. Although i declared that the player should start with the „idleDown-animation“, it starts with the „idleX-animation“.
And how can i disable the flash (small fade in/fade out) of my player when it spawns?
As allways any help is highly appreciated! Thanks!