Suggestion: Pathfinding Compare MovingAngle

0 favourites
  • 7 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • We basically need an condition to pathfinding behavior: Compare MovingAngle

    It's helpful to make animations.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Create an instance variable that is constantly set to Pathfinding.MoveAngle

    Compare that instance variable?

  • Ok suppose you have 8 animations.

    Now take those 8 animations and rename them something like myaniamtion0, myaniamtion45, myaniamtion90, myaniamtion135, myaniamtion180, myaniamtion225, myaniamtion270, myaniamtion315, and myaniamtion360.

    Now suppose that rather than compare the angle you set the animation based on the angle like:

    mysprite set animation to "myanimation"&int(mysprite.Pathfinding.MoveAngle)

    What do you think would happen?

  • Create an instance variable that is constantly set to Pathfinding.MoveAngle

    Compare that instance variable?

    Oh yes... I forgot to use that method... let me try that. Thanks!

    Ok suppose you have 8 animations.

    Now take those 8 animations and rename them something like myaniamtion0, myaniamtion45, myaniamtion90, myaniamtion135, myaniamtion180, myaniamtion225, myaniamtion270, myaniamtion315, and myaniamtion360.

    Now suppose that rather than compare the angle you set the animation based on the angle like:

    mysprite set animation to "myanimation"&int(mysprite.Pathfinding.MoveAngle)

    What do you think would happen?

    newt I almost have your method BUT you didn't tell about what event we should create.

    Perhaps "System > Compare two values" honestly, I don't really use system because it only picks one instance number 0 as default, not multiple instances.

    Actually, Excal posted about instance variable, I hope it would work.

  • What do you think would happen?hmm...

    <font size="1">sorry, couldn't resist :)</font>

  • Its when ever you want it.

    Is moving works nice. If you're worried about it being set too often add a sub event with every x seconds, but really it should be negligible.

    Edit:

    tulamide

    Abracad-ampersand

  • I've been working with Pathfinding behavior for a sprite character that has 'run' animations in four-directions on a 3/4 perspective playing field. I've struggled with the same issue of triggering the correct animation when the sprite is moving along the path.

    Pathfinding.MoveAngle changes constantly and in fractions of a degree, so the suggestion Newt offered inspired a solution that works for me. I created a global variable set to:

    PathfindingMoveAngle (Global Variable): floor(sprite.pathfinding.moveangle)

    Since this still frequently returns angles between the four directions of 0,90,180,270...I created a second global variable that converts any angle to one of the four angles aligned with the desired direction.

    For example, any angle between 46 and 135 is converted to 90. Then I set the animation speed to Pathfinding.Speed/2 (after fiddling around with different frame-rates).

    Additionally, I set a condition that tests the pathfinding.speed, so if the sprite's pathfinding speed is below 1 pixel per second, it defaults to an 'idle' animation triggered by the last 'run' animation that just finished.

    I named my animations based on the angles governing the four-directions?as Newt suggested?and it's worked pretty well.

    Thanks,

    Jason

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