Okay Really stumped on this one

eemachalaeemachala Member Posts: 21
edited November -1 in Working with GS (Mac)
Thought it was simple but cant figure this out and got some advanced rules on this npc's... Taken from animation left and right tutorial. Self.motion.linear velocity x < 0 Self.motion.linear velocity x > 0 used this and ruleset to have animation play ... works nice but just for left and right... When i try to throw in the Self.motion.linear velocity y < 0 & Self.motion.linear velocity y > 0 .. the character animations flicker between x and y directions obviously the tutorial works left and right, but how could i fix this, there is a deadzone where both x and y rules are active. think something with angles but not sure anymore tried so many things...

Fyi i have 4 animations for movement in 4 directions up down left right .

Comments

  • msonesmsones Inactive, Chef Emeritus Posts: 75
    The problem is probably that you've got two animations that are triggering simultaneously, since two of your conditions can coexist at the same time. Try adding another condition to trigger a particular animation - for instance, When "Self.motion.linear.velocity.x < 0" AND "Self.motion.linear.velocity.y=0" then you play your "move left" animation; when x = 0 and Y is < or > 0, then you play your up or down animation, etc.

    Without knowing more about when / how your NPC starts and stops movement in various directions, that's all I can suggest - maybe give us some more details / context if this doesn't work?
  • eemachalaeemachala Member Posts: 21
    Thanks Msones yes I should have stated what im doing since tried a few things. Yes this does work and i'm useing it, but for only for a part. See I'm use exactly that for having npc's walk to waypoints or actors self.positions. And i have some actor attributes for tracking last direction traveled and i use that for idle facing. and then later for death and attacking animations they all for nice... But here where it wont work... Im useing distance from Player controlled actor ... so i rule set alot of my npc's on some more states boolean, combat and aggro when you get to close less than X NPC will engage combat set to true and he attacks etc, if you run/move away from NPC actor greater than distance rule sets combat to false and aggro to true. This sets a rule to to follow player controlled actor using move to behavior setup like this self.Position.X +( game.PLayerX - self.Position.X )/4 & self.Position.Y +( game.PLayerY - self.Position.y )/4.

    So when I set him off in a move direction he walks fine in all 4 directions... when i engage him him by breaking range limit... he follows does all his bits facing correct direction chasing but that it... just faces the direction no animations while moving... im using this to get my distance from player this is constraint to npc magnitude(abs( self.Position.X - game.PLayerX ),abs( self.Position.Y - game.PlayerY ))

    Besides When this is called "Self.motion.linear.velocity.x < 0" AND "Self.motion.linear.velocity.y=0" then you play your "move left" animation;" the only other rule checked is a boolean to check if npc is in combat cause combat if used at very close range switches to attack animations..

    Im really stumped.... is it to do with the way im following my player? got the chase code from how to section...
  • eemachalaeemachala Member Posts: 21
    Think it's more to do with linear.motion = 0 cause with out it they will animate but flicker cause conflicting directions and with it that won't animate at all..
  • eemachalaeemachala Member Posts: 21
    is there anyway to use an angle maybe vectorToangle... like using the angle at a diagonal to north and west and north east so north will go up and animate up if angle is 45 degrees off north in both directions anything more changes animation to left or right? could this be done tried doing something like it but cant get it working?....
  • eemachalaeemachala Member Posts: 21
    Okay So thats it my character/Npc or walks or animated in the direction he is going if its a straight angle exactly. How can i have that actor calculate his angle traveling so i can put in greater than and less than rules, so let say left movement animation works plus or minus so many degrees off the left movement on linear.velocity.x

    been browsing forums looking for the answer just cant find it
  • eemachalaeemachala Member Posts: 21
    Okay figured it out i think... got 3 directions working left up and down ... right is wonky... Well i thought i tried this earlier but think i used self.poistion.x by accident ... vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ) constrained to actor attribute i call NPCangle-which is an angle...

    used for example self.NPCangle > 135 and self.NPCangle <215. and left works great following suit with the rest... but when i get to going right i had to use the left over angle comes to for me <30 and >315... and no animation.........

    if i put just one angle 30 or 315 degrees it works just leaves me with a small deadzone where actor will drag instead of animation because has no rule .....

    I think this is because angle looks like this 30---1,0,360---315, think the zero is messing with something
  • eemachalaeemachala Member Posts: 21
    WHOOOHOOO ... Got it yeah its something to do with angle and rule when its switches over the 0 degree threshold.... added to rules one

    self.NPCangle > 315

    self.motion.Linear Velocity.Y NotEqual to 0

    and another rule with not equal 0 and < 30

    Thank god was about to change it to a self.NPCangle to an integer and use angle 180 through -180

    Well on to my next task
  • eemachalaeemachala Member Posts: 21
    FYI you also need a self.motion velocity X rule also for cover zero angle... bit redundant to have 3 separate rules for right movement but it works finally.... Glad to take any advice on how to lessen it to one simple rule for right motion, I surly could do with a few less rules in my npc actors :)
  • Mikey989Mikey989 Member Posts: 1
    dude i can make my sprite animate right but when i try make him animate left he just slides backwards? can you help?
Sign In or Register to comment.