How can I stop the "8 Direction" behaviour doing this?

0 favourites
  • 11 posts
From the Asset Store
Skin it
$20 USD
A skin plugin and behavior to add a skin system in your game.
  • Sorry for the shoddy title, not enough space to explain what I mean!

    I've been using Construct 2 for about a week and at seemingly complete random the 8 Direction behaviour in all of my projects is changing Vector X / Y 'incorrectly'. What's happening is when I'm moving just left, the Y Vector will set itself to a number above 0. When I'm moving just up or down, the X Vector will also then set itself to a number above 0. I have no idea why it's suddenly decided to do this.

    The problem with this is that any events I have using the 8 Direction condition "is moving" now don't work properly. Because the player can be right up against the a wall, press the arrow key into it, and since the Vector Y / X will set itself above 0 for some reason, the player will now play the walking animation into the wall, because they are apparently "moving". (The other Vector works as normal.) Something interesting is that when it's set to whatever number, the character will not actually move in the direction at all. Another interesting thing is that pressing left will keep the Vector Y to 0, but pressing right will set it above 0 for whatever reason.

    I looked this up here on Scirra and found only one other person who had this issue (they had submitted a bug report), and Ashley had replied stating it would be something to do with math calculations in the events. I looked through my own events and couldn't find any issues, so decided to make a completely fresh project with no events at all with one single 8 Direction sprite. And to my surprise, this issue happened there as well!

    So now I'm guessing I've changed some setting somewhere by accident..? I'm really not sure where to go from here. I can't really go any further with some projects because I can't test anything to do with animations properly whilst this bug still exists.

    If you've read all of the above and don't understand what I mean at all, that's okay, I made a 1 minute video to show what I mean visually. Hopefully by watching this the issue should become a lot more obvious to see.

    The link got removed for my reputation, so I'll break it up here. "Piece together at your own risk" or something, I guess? "youtube .com / watch? v=LbIhlwR5spQ"

    Hopefully this is something obvious I'm missing, I'd really like to get this back to normal, I have no idea what's caused it. Thanks in advance!

  • A video is not really of much use.

    It would significantly speed up the process if you provided a small example of a project that has the problem you describe, and exact steps to reproduce.

    That way, we can determine whether you have altered something or not, or even whether you have uncovered an actual bug.

  • It would significantly speed up the process if you provided a small example of a project that has the problem you describe, and exact steps to reproduce.

    Here's a .capx file link:

    This got removed as well.. here's a broken up version:

    https:// drive. google. com/ open?id=0Bz6k_T7ICBNmNGpaZnpaR29YSzg

    All that's in this is a sprite with an 8 direction behaviour. That's really all that's in here. You can see this issue happening if you run in debug mode, select the sprite, and check the Vector X and Vector Y values while moving in a straight line.

  • I downloaded your file and checked my project, and it's completely true. The perpendicular vector value does change once you reach your maximum speed in any direction, though it doesn't actually move the player in that direction. This really looks like a bug.

  • I downloaded your file and checked my project, and it's completely true. The perpendicular vector value does change once you reach your maximum speed in any direction, though it doesn't actually move the player in that direction. This really looks like a bug.

    It's really strange. If I do this on my project that was working just fine a few days ago, even though the values go up, the player never actually moves in that direction at all. I tested this by walking left into the wall for a while with the Vector Y showing that I should apparently be moving up, as well as making a very long canvas, but I didn't go a single pixel up. It's annoying because like I said in my post, it's completely screwing over my animations on that project, and I can't really get around it.

    Strangely, I never updated my Contruct 2 but this still suddenly happened out of the blue. If you make a new project yourself just like I have done here, can you check if it happens for you as well? The only thing I can think of is that there's some setting I've changed unknowingly that carries over to the .capx which is causing it to happen on every project I export / view. The video I have on my original post is exactly how I made the .capx, it's only a few steps long.

    "[r178] 8-Direction bug" is the name of the original thread with this issue, that Ashley replied to. I would link it to you but, you know.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ashley's answer is still valid. Computers produce small rounding errors all of the time. You have to deal with them. If you are basing your animation on VectorY=0, don't. Check for < 0.1, or something like that.

  • Ashley's answer is still valid. Computers produce small rounding errors all of the time. You have to deal with them. If you are basing your animation on VectorY=0, don't. Check for < 0.1, or something like that.

    I'm basing it on the "is moving" 8 Direction condition. I can't change it to be like that because there's points in the game where your movement is heavily slowed - and what if those numbers went higher for no reason as well?

    I find it hard for this to be a rounding error because there's no calculation to even be rounded. Moving right keeps it on flat 0. All the other directions range from around 1 - 6 in the example I provided, but it's different for higher speeds. This has happened completely randomly and it doesn't make sense for it to happen.

    When you press just left, you're only moving left. You're not moving a little upwards or downwards at all - it's just left. If pressing right can get this done no problem, and it used to work just fine for all sides, why does this have to happen randomly now? With the main project I have involving this I really can't make a workaround for this without having it not happen. There isn't even a single event within the example project.

    Even if I did manage to get around this myself, it's still a big issue, because the "is moving" condition is practically worthless when this is happening. I don't know much about the program myself compared to pretty much anyone else around here, but I have a feeling Ashley was meaning calculations just within the events of a project.

  • Ashley's answer is still valid. Computers produce small rounding errors all of the time. You have to deal with them. If you are basing your animation on VectorY=0, don't. Check for < 0.1, or something like that.

    It isn't an issue for my project, but the vector values can be significantly off.

    I'm not using vectors to determine things in my game, but even <0.1 would miss it--it's over 3.

  • You have to read the value correctly: it is 3 times 10 to the power of -14, which is: 0.00000000000003. Clearly this is 'almost' zero.

  • :) You have to read the value correctly: it is 3 times 10 to the power of -14, which is: 0.00000000000003. Clearly this is 'almost' zero.

    What's causing it to be above flat 0 though, when going right works perfectly fine in comparison and this never used to happen before?

  • Depends on the calculation - that is the nature of the problem. I can't answer why this didn't happen before.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)