RPG Walk - Bullet Direction > Animation

Get help using Construct 2

Post » Fri Jan 11, 2013 8:41 pm

Hi guys,

I'm trying to figure out how to have a character have 4 directions in his animations (Up, Down, Left and Right). I've given him the bullet movement, and wish for the animation to be selected based on the direction he is moving in.

I am testing this with 3 versions of the same sprite.

I have tried a For Each command, followed by a 'if bullet angle is between 45 & 135 set animation to 'Down', and it appears to work, but If I add in the other directions, the characters just pretty much settle on looking down all the time. Quite frustrating.

I came from Multi Media Fusion, where the system would pick the animation angle based on the sprites movement, and am surprised something like that still doesn't exist for C2 (which is sooooo much easier to use in a lot of other ways, I should add).

In any case, I'd apprecaite any help.
please see the capx here
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 931
Reputation: 9,360

Post » Fri Jan 11, 2013 10:31 pm

The animations still doesnt match with most of the angles but I guess it can be solved by trying.

Please have a look at the https://www.dropbox.com/s/7dfjsicblib0kua/RPGWalk.capx
B
3
Posts: 8
Reputation: 343

Post » Sat Jan 12, 2013 12:04 am

@AnD4D : I tried opening the capx, but all I see is a random moving character with 1 animation, so I don't know what's going on with the problem you were having in the OP.

Anyways, if the character is player-controlled, I'd consider tying the animation into what key is pressed for movement; if the character is computer-controlled with the bullet movement, try using the character's angle to set the animation. I don't think you need a loop to do this; set up the event normally to check the character's current angle and then assign/change the animation based on the result.

Something like:
character.is between angles 0-90 = character.set animation
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Sat Jan 12, 2013 12:34 am

I had this exact same issue! I originally tried it the same way as you and got errors. Then someone recommended that I try using anglediff instead, and for reasons unknown to me that worked while comparing angles normally did not. I did this:

First, add a variable to whatever is moving called 'Angle Tracker' or the like. Make it update every tick to that object's Bullet Angle of Motion.

-For each + Bullet Speed 0 (inverted):
-anglefiff(Object.AngleTracker,0) < 45: Set animation to 'right'
-anglefiff(Object.AngleTracker,90) < 45: Set animation to 'down'
-anglefiff(Object.AngleTracker,180) < 45: Set animation to 'left'
-anglefiff(Object.AngleTracker,270) < 45: Set animation to 'up'
-Object Bullet Speed = 0: Set animation frame to 0.

And there you have it! Hope that helps.
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Post » Sat Jan 12, 2013 9:42 pm

Brilliant @Tobye!

That's worked fine. I've updated the capx in the first post in case anyone else wants to see it.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 931
Reputation: 9,360

Post » Sun Jan 13, 2013 3:08 pm

No problem @And4D! I also spent the last 3-4 days making a sort of pathfinding which might interest you (fully evented). It works very well for getting around moderately complex paths (4-5 turns), now I am just trying to get the enemies to chase the player correctly (it worked fine until I introduced flying enemies - GAH! I should have just left it alone!). The main advantage in my point of view is it is not a plugin so won't interfere with any wrappers or the Scirra arcade and also has great performance on mobile.

So if you would like to see it let me know, it should be ready to show in about 4 days and I could do with some suggestions and bug testing as I will be using it for many projects.
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Post » Sun Jan 13, 2013 6:04 pm

i use this code for doing a adventure game but i don't use bullet movement i must replace this code:
system:everytick   sprite: set angletracker to sprite.bullet.angle of motion
i use the "move to" behaviour and "touch" object
B
6
Posts: 28
Reputation: 831

Post » Sun Jan 13, 2013 8:48 pm

Hey @Tobye,

I'd definitely be interested. I was literally just about to try to tie in the AStar pathfinder to this, when I thought I'd check on the forum.

Cool stuff!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 931
Reputation: 9,360

Post » Mon Jan 14, 2013 6:01 am

@And4D - Alrighty, I'll send you the capx in a few days. In the meantime, if you do try out the Astar pathfinding, let me know how it goes. I had a few issues with it (beyond being only grid-based) so never even got to fully testing it.

If you don't mind grid-based pathfinding though, and aren't trying to publish to phones, Kyatric's pathfinder works great. I was planing on using it, but it will freeze for about 2 seconds every time it needs to generate a path when on mobile devices.
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Post » Mon Jan 14, 2013 7:56 pm

@AnD4D - I sent you a link to the capx via pm. There is a lot more detail in the message, so please have a look and tell me what you think!
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests