How do I make a sprite move in four directions?

0 favourites
  • 9 posts
From the Asset Store
Hand-animated Sprite Base for isometric game/animation development
  • Hi guys, my problem is basically with logic, I'm confused about what I should do to make this sprite move in four directions with the simulate controls.

    Here I'm using that "edge maker" thing, which is very useful when you want your sprite to move in just two directions, but I want it to move in four, and I'm having problems at it.

    Huh, I guess a screenshot may help:

    This sprite, as you can see, has a text instance variable called direction that is used to determine the movement orientation through the event actions.

    The problem is that the sprite goes to a completely unexpected direction when it hits the boundary maker object, if it was meant to go to the right, it goes up instead, and sometimes it doesn't even hit it at all, it just pass through it like there was nothing there.

    Well, that's it, hope you people can help me! Oh, and I'm sorry for my rusty english , I'm still learning!

    Thanks in advance!

  • Seems kind of simple, but have you tried setting the 8direction to four-directions only in it's settings for the object that has the behavior?

  • The problem is that in your logic, you have told the variable to change based on it's condition... but it is changing the variable several times in the single event because it's processing your code in-line. You need to have some way of changing the variables in a more controlled way. Currently if the variable is "left" it changes to "right" but is then immediately pocessed from "right" to something else. Maybe adding a "wait 0 seconds" after each state change might work... otherwise you need to break down your state change engine to be more controlled over the variable adjustments.

    ~Sol

  • Add 'else' in 29, 30 & 31.

  • Add 'else' in 29, 30 & 31.

    Yeah, this should also work

    ~Sol

  • Seems kind of simple, but have you tried setting the 8direction to four-directions only in it's settings for the object that has the behavior?

    Yes I tried! But it didn't work !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The problem is that in your logic, you have told the variable to change based on it's condition... but it is changing the variable several times in the single event because it's processing your code in-line. You need to have some way of changing the variables in a more controlled way. Currently if the variable is "left" it changes to "right" but is then immediately pocessed from "right" to something else. Maybe adding a "wait 0 seconds" after each state change might work... otherwise you need to break down your state change engine to be more controlled over the variable adjustments.

    ~Sol

    ey, thanks you so much for trying to help me! I've found a simpler and effective solution to the problem!

  • Add 'else' in 29, 30 & 31.

    Thank you guy for trying to help me! Really appreciate

  • Hey people, my thanks to all of you for the help! All your tips helped me come up with a simple solution that I could not see! Here it is:

    Thanks one more time! Wish you the best.

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