0 Favourites

RPG Walk - Bullet Direction > Animation

  • 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 <img src="smileys/smiley5.gif" border="0" align="middle">

  • 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 dropbox.com/s/7dfjsicblib0kua/RPGWalk.capx

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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

  • 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.

  • Brilliant Tobye!

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

  • 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.

  • 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

  • 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!

  • 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.

  • 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!

  • 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.

    Hello Tobye,

    I'm new to construct and have no experience in it what so ever, can you please tell me how you got animation working with bullet, I made so the character follow where I click with the mouse.

    I tried calling "Player.bullet.AngleOfMotion = 180 tehn set direction to "up"

    also tried player-angle < 90 = set direction to "left"

    can you please aim me forward the right direction

    here is my file:

    dl.dropboxusercontent.com/u/57001596/test.zip

    My goal is where I left click, the player will go and play the right animation for it

  • Hello Tobye I know this is kind of an old post and you probably don't have the file but I was wondering if you can send me the file also I have a project and I kinda need help with the movement more precisely collisions with a tile map.

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