rotate to player?

mrcrumb

  • Posts: 7
I hate asking so many questions, but after playing around with this, I can't quite figure it out.

How would I get an AI to flip it's direction based on the players direction? Seems easy, but when I try, the AI rotation is flipped upside down / generally completely wrong. It just looks a bit silly having a enemy chase me backwards ;)

I've tried to pull things from examples, but without much luck - is there a behavior I'm missing that could simplify this? I'll keep searching, but I wanted to post this just in case I was missing something.

Alexin

  • *
  • Posts: 3132
Seems easy, but when I try, the AI rotation is flipped upside down / generally completely wrong.
Make sure to use consistent units. For example, the block "sin, cos, tan" expects radians while "direction of Self" returns degrees.
Angles are measured starting from the right and clockwise (ie. right=0º, down=90º, left=180º, top=-90º ).
"Find the fun"
alexin@stencyl.com

Hectate

  • *
  • Posts: 4643
Another thought is (and it depends on the enemy's sprites) whether or not you gave him an animation to face the other direction. For instance, he has a "Walk Left" but does he have a "Walk Right" that is getting used also?

It sounds like you're going for a top-down view but saying that your enemy is "flipped upside down" seems like the wrong animation is or is not playing also.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

mrcrumb

  • Posts: 7
It's actually a platformer - I have a flying enemy with (currently) 3 frames of animation. I just needed it to flip around so it's always facing the player while chasing.

And then I just realized...I probably can't mirror anything. Stuck in 3d land where I could just flip double sided actors and be done with it. Wow. I feel dumb now..lol.

Alexin

  • *
  • Posts: 3132
Mirroring can be done using a scale operation, be it in 2D or 3D.
"Find the fun"
alexin@stencyl.com