Suggestion: Pathfinding Compare MovingAngle

Discussion and feedback on Construct 2

Post » Sun Aug 25, 2013 11:27 pm

We basically need an condition to pathfinding behavior: Compare MovingAngle

It's helpful to make animations.
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Sun Aug 25, 2013 11:48 pm

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

Compare that instance variable?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Mon Aug 26, 2013 12:59 am

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?newt2013-08-26 01:01:08
Image ImageImage
B
168
S
50
G
164
Posts: 8,228
Reputation: 105,575

Post » Mon Aug 26, 2013 1:07 am

[QUOTE=Excal] Create an instance variable that is constantly set to Pathfinding.MoveAngle

Compare that instance variable?[/QUOTE]

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


[QUOTE=newt] 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?[/QUOTE]


@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.Joannesalfa2013-08-26 01:08:06
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

Post » Mon Aug 26, 2013 1:16 am

[QUOTE=newt] What do you think would happen?[/QUOTE] hmm...
sorry, couldn't resist :)
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Mon Aug 26, 2013 1:17 am

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-ampersandnewt2013-08-26 01:20:51
Image ImageImage
B
168
S
50
G
164
Posts: 8,228
Reputation: 105,575

Post » Mon Sep 23, 2013 6:17 pm

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-directionsas Newt suggestedand it's worked pretty well.

Thanks,

Jason





B
8
S
2
Posts: 9
Reputation: 1,809


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests