JurassicPark's Forum Posts

  • 4 posts
  • If you are moving it via events (e.g. lerp), you just need to do this:

    every tick:

    instance variable angleOfMovement = angle(previousX, previousY, self.X, self.Y),

    previousX = self.X

    previousY = self.Y

    Okay, I've done this to get the angle.. now I'm just having trouble setting the condition based on angleOfMovement. It appeared to be working for finding angles between 0-45, 45-90, 225-315, and so forth. But when it crossed over zero, like between an angle of 315-45, it seems to break.. I assume because it's reading the angles as values.

    The logic I keep going to is to use:

    System - In Between Values

    315 < npc.angleOfMovement < 45

    Also, I tried replacing the values with angles so:

    Angle(0,0,1,-1) < npc.angleOfMovement < Angle (0,0,1,1)

    There is also the "between angles" and "within angle" on the NPC, but these appear to be locked to the original npc angle parameter and not my angleOfMovement instance variable??

    Hopefully the above problem makes sense.. I just want to perform an action based on whether the moving angle of the sprite is within 45 degrees of 0, 45,90, 180 degrees, etc.

  • Ah, that is simple. Thanks Nimtrix.

  • Thanks for the response, Sqiddster

    I was originally just moving the NPC by the Lerp event.

    PreviousX is not an accepted angle parameter. Did you mean Self.PreviousX with PreviousX being an isntance variable?

    Now I made a new version implementing 8-directional NPC movement. This seems to be working:

    Every Tick:

    Move NPC 1 pixel at Angle of angleOfMotion

    Every 3 Seconds:

    Set angleOfMotion random(360) + monster1.8Direction.MovingAngle

    I am then using Between Values of angleOfMotion to play the correctly oriented animation.

    Now a new problem I have is that as soon as one instance of the NPC moves at a certain angle to change animations, all the other instances change animations as well. I assume this is a Unique ID problem, but I was unable to find an answer in the FAQ.

    Is there a simple way to have any Animation changes, other changes, etc. apply only to the UID which met the conditions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello All,

    I've been searching through many other threads and finding variations to this NPC angle issue, but can't seem to find the solution, though I'm sure it must be a simple one.

    I am very new to Construct, and right now I'm experimenting with a top-down 8-directional NPC movement.

    I am just wanting to base the angle off of the NPC's own directional movement, (not compared with the player or another entity's position)

    Basically all I want to do is:

    • If NPC angle is within 45 degrees of north (260?) then play "north" animation.
    • If NPC angle is within 45 degrees of south (90?) then play "south" animation.

    In my event sheet I'm using: NPC 'within 45 degrees of angle x' then 'Set Animation x' for both of those conditions.

    However when I play it, the NPC will not deviate from its original animation no matter what angle it is moving at.

    (Btw, For NPC movement, I'm using a Set Position Lerp to have the NPC automatically follow the player's position. )

    Any suggestions? :)

  • 4 posts