How do I make a sprite change directions on mouse angle?

0 favourites
  • 5 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • The title is messy. I dont know what to call it. But anyway how would I go about making a game with isometric sprites change facing direction depending on the mouse location. Similar to using rotate towards angle. But when its rotating, it will change sprites.

  • Hi,

    You mean something simple like SYSTEM Every Tick

    Player Set angle towards Mouse X Mouse Y?

  • Hi,

    You mean something simple like SYSTEM Every Tick

    >> Player Set angle towards Mouse X Mouse Y?

    Similar, What i mean its when the mouse rotates around the sprite the sprite will change its animation direction. Something similar to the Alien Shooter Series.

    Actually a better comparison would be this

    The way the sprite animation changes based on the movement. Except I just want the effect but not for movement. I just want the effect for mouse look.

  • Ok, I understand better what you want.

    So you need to explain to the computer which animation to play for every possibility of movement. There are always many ways, but in my projects, and I am not some super expert, I am using angles to do that.

    To do this you need to picture in front of you the angles: 0 is on the right side, -90 is up and 90 is down and so on.

    So you need to setup several events to cover each range and you say:

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 0 and -30

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 0 and +30

    go right

    and set animation to "right"

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 30 and 70

    go top right

    and set animation to "top right"

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 70 and 110

    go up

    and set animation to "up"

    etc

    it will also help you to put a temporary text showing current angle on the screen so you can solve bugs around angle 0

    good luck

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, I understand better what you want.

    So you need to explain to the computer which animation to play for every possibility of movement. There are always many ways, but in my projects, and I am not some super expert, I am using angles to do that.

    To do this you need to picture in front of you the angles: 0 is on the right side, -90 is up and 90 is down and so on.

    So you need to setup several events to cover each range and you say:

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 0 and -30

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 0 and +30

    go right

    and set animation to "right"

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 30 and 70

    go top right

    and set animation to "top right"

    If the angle(Player.X,Player.Y,Mouse.X,Mouse,Y) is between 70 and 110

    go up

    and set animation to "up"

    etc

    it will also help you to put a temporary text showing current angle on the screen so you can solve bugs around angle 0

    good luck

    Alright, I'll try it.

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