How do I set animation to line of sight angle?

1 favourites
  • 3 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • I have 8 animations, each facing a different direction.

    Up

    UpRight

    Right

    DownRight

    Down

    DownLeft

    Left

    LeftUp

    The line of sight is 360, when a object enters the line of sight, Is there any way to have them face the direction of the object that is detected in the line of sight?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Set your animation names to "0" (right), "45", "90" (down), "135", "180" (left), "-135", "-90" (up), and "-45".

    Then use the following event to determine the animation to play:

    + LOSObject: Has LineOfSight to Target image point 0

    -> LOSObject: Set animation to str(round(angle(LOSObject.X,LOSObject.Y,Target.X,Target.Y)÷45)×45) (play from beginning)

    Here's a small c3p to illustrate: onedrive.live.com/redir

  • Set your animation names to "0" (right), "45", "90" (down), "135", "180" (left), "-135", "-90" (up), and "-45".

    Then use the following event to determine the animation to play:

    + LOSObject: Has LineOfSight to Target image point 0

    -> LOSObject: Set animation to str(round(angle(LOSObject.X,LOSObject.Y,Target.X,Target.Y)÷45)×45) (play from beginning)

    Here's a small c3p to illustrate: onedrive.live.com/redir

    thx!

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