got a little problem here: I made a simple 2D game to practice Blueprint scripting. Everything works fine so far, with the little but grave exception that when I jump and keep the jumping direction pressed, but do a direction change the exact moment my character touches the ground, he rushes away in the direction he is now facing.
I’ve made a short video showing what my problem is (it’s kind of hard to explain). It occurs first at about 0:17 and can be seen four times: http://youtu.be/27eWYzU-CTI
I’ll attach my movement Blueprint as well (contains additional flipbook settings).
Could this be a mistake I made or is this some kind of standard “feature” that I do not know of? Or could it be an engine bug?
Thanks for the help!
PS: I use some sprites from Nintendo in the video. I hope this is fine, as it is only a practice game. If this is a problem, please feel free to remove the link.
I’ve been looking at your question for a while and I think I might know why it’s happening.
I’m not completely certain on how your axis value is set up, but I think if you’re turning when you land, it causes an unexpected Axis value which increases the Scale Value in your Add Movement Input function to a crazy-high amount. That’s why you’re suddenly flying off to the side. If you want to check and see if that’s the problem, you could try having a Print String node that prints the Scale Value value and see if it goes crazy-high when the bug surfaces. Just a suggestion.
thanks for your time and the suggestion! I’ve just tried it, but the value shows no abnormality whatsoever (neither the axis value, nor the final input value, I looked at both).
Interestingly enough, I made these 2 new observations:
the phenomenon only occurs when I keep the first directional key pressed right up to the moment when I want to switch directions. Leaving the button unpressed just a split second earlier doesn’t trigger the “side jump”.
I was able to reproduce the phenomenon while walking on the floor as well, if the timing is right.
Do you think the bug is caused by the game taking a left and right input at the same time? Maybe use a Branch to prevent both inputs from happening together and see if that helps?
Hm… How would you set up that branch? Sorry, I seem to be slow on the uptake at the moment ^^ Maybe I should take a break. This is what I just tried, but it does not solve the issue:
Hey, no worries. I realized I’m being a little slow on the uptake too. I finally figured out that you’re using a modified version of the Sidescroller Blueprint, so I opened that up and took a look. It looks like the way the Sidescroller Blueprint is set up prevents taking left and right inputs at the same time, so that’s not the problem.
I’m going to try to emulate your blueprint setup and see if I can reproduce the bug. I haven’t succeeded yet, but I’m working on it.
In the meantime, have you tried wiring InputAxis MoveRight directly to Add Movement Input? If that fixes the problem, that means that the bug involves the Flipbook and Set Actor Rotation part of the blueprint.
Oops. I could have mentioned that I used the template ^^
I tried wiring the Inputaxis event to the AddMovement, but the error still occurs. In case you’re not able to reproduce the bug, can I be on any assistance, maybe by putting the whole project into our SVN?
If you could send me your project, that would definitely be very helpful. Rather than SVN, could you upload it to Dropbox or Mega and send me the link over private AnswerHub messages?
sorry for the late answer. I have uploaded the project to my Dropbox. Now this may sound like a stupid question - but how on earth can I send a private message? ^^
Okay, I’ve made a lot of discoveries, but the issue is still eluding me.
Here’s what I’ve got so far:
First off, the ‘flying to the far side of the screen’ bug is caused by a smaller ‘teleport (or move very quickly) a short distance’ bug. Even if you’re on the ground, tapping A and D repeatedly can sometimes make your character dash to the side a little bit. If you do that while standing on a block, then you’ll fly off to the side (like you showed in your video).
However, that little teleportation bug is crazy hard to track down. I’ve removed almost all of the blueprint and nearly all of the related assets, but the bug still persists.
I’ve deleted everything else. The only things that remain are this, and the TetriskCharacter Defaults. The character is no longer visible, but I have the camera following him so I can tell when he teleports, and it still happens. That means it’s not part of your event graph, because the Blueprint 2D Side Scroller character doesn’t have this bug, even when you simplify his blueprint to this.
The only thing I can think of to try now is to make a new Character and just copy the old one’s components and stats to the new one until the bug resurfaces.
Yay! I was just creating the new character as you proposed and I think I found the problem! I’ve set the “Ground Friction” to a very high value to better imitate the movement of Mario. Seems like 1000 was a litte too much I’ve reduced it to 200 and wasn’t able to reproduce the bug anymore.
Would be great if you could try and confirm this discovery!
Excellent! When I set the friction to 200, I can still reproduce it sometimes (by tapping A and D repeatedly), but setting it to an even lower number (like 5) makes it completely disappear. Finally!
I’m glad we finally found the root of this problem, I was getting pretty concerned!