(solved) Angle in turret behavior

  • hi there :D!

    I'm having trouble figuring this out.

    I'm making a RTS type game. And my sprites have several frames to show which angle they're looking at using the "MovingAngle" expression of the pathfinding behavior.

    For example this: "round((unit.Pathfinding.MovingAngle+45)/45)"

    That particular unit has 9 frames (frame 0 is empty). And it works fine :D

    However, they also have the turret behavior, so they use their pathfinding.MovingAngle when they don't have targets, but for when they do have targets, I don't know what to do. The "angle(x1,y1,x2,y2) expresion only give me negative numbers from 0 to -180, unlike MovingAngle that returns 0 to 360. So I can only use half the angles when in range.

    The idea is that when they have targets they look at them when they move.

    I hoped something like this: "round((angle(unit_Builder.X,unit_Builder.Y,F_Enemy.X,F_Enemy.Y))/45)" might have worked. but it doesn't =(

    Any suggestions? Am I missing something? D:

    (just in case, i AM using the pick target by UID)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ok, I figured it out... i just had to add a +180 on the calculation....

    -180+180 = 0

    180 + 180 = 360

    and there i go.

    stupid angle expression.

    "round((angle(unit.X,unit.Y,Enemy.X,Enemy.Y))/45)"

    I also had something else wrong.

    This is the correct form:

    "round(angle(Enemy.X,Enemy.Y,unit.X,unit.Y)+180)/45"

    or the result is inverted =(

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