How do I correctly set an animation dependent on a Bullets AngleofMotion?

1 favourites
  • 7 posts
From the Asset Store
Ninja char for your game! Make your own Shinobi game with this art.
  • Hi everyone, struggling with this one a little bit for some reason. I think it's to do with the negative values for Bullet.AngleOfMotion but here's what my code looks like

    However our little headless butcher does not seem to cooperate with these angle settings.

    Is there a better and more refined way to do this?

  • Yeah, that's why there are special conditions for angles. You can use "Is between angles", or it may even be easier to use "Is within angle". For example, "Is within 45 degrees of 180" for "Walk_right" animation.

  • Hi dop2000, thank you so much for helping me with this (and the previous one too!) You're a legend!

    So I have tried using 'Is Between Angles' and 'Is Within Degrees of Angle' but they don't seem to correctly trigger the animations either. Would it be possible for you to lay out your best way of doing this so that all instances on a layout follow the rule?

    Just noticed your BuyMeACoffee Link so enjoy the coffee, and anyone else reading this ... buy Dop2000 coffee :)

  • Hey, thanks for the coffees!!

    If you have multiple instances of this object, you will have to do this in "For Each" loop.

    For each Sprite
     Sprite.Bullet.angleOfMotion within 45 degrees of 0 : Set animation "Right"
     Sprite.Bullet.angleOfMotion within 45 degrees of 90 : Set animation "Down"
    .....
    
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you dop2000

    So does this look good to your expert eyes?

  • Looks ok to me. Does it work?

    It is also possible to do this in one line of code and without the loop:

    Sprite set animation to anglediff(self.Bullet.angleOfMotion, 0)<45 ? "Right" : anglediff(self.Bullet.angleOfMotion, 90)<45 ? "Down" : anglediff(self.Bullet.angleOfMotion, 180)<45 ? "Left" : "Up"
    
    
  • Thank you for that additional code, I just tried that and it seems to be the thing it needed. As always, utter legend!

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