My project is in 2D so I am using my own player controller and animation system. When I talk to an NPC, I would like to set their animator to face the player, similar to how it's supported in 3D. However, since it's in 2D, a new animation sprite needs to be played instead of a simple game object rotation.

To do this I can calculate the x and y distance between the player and the NPC. Then, depending on which is greater, and if the distance is positive or negative, I can set the NPC to face 1 of 4 directions.

The only thing is, I'm not sure how I can do this in ORK. This calculation seems to be too complex for the editor's event system, so is there a way I can put this in the scripts? What would I need to do to go about that?
  • There's the Check Orientation step to determine if an object is left, right, in from or in the back of another game object. Use that step and face the NPC accordignly afterwards.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks for the response. I hadn't seen check orientation before so I spent some time testing it out. Couldn't really get it to work though.

    Since my game is in 2D, the characters only move on the X and Y planes. I could get check orientation to correctly detect when I was to the left and right of them, but not to the front/back (more accurately repurposed as below/above in 2D). I tested in the editor and changing the Z values which made it trigger right.

    Hm, maybe I could write a script that changes each object's Z value based on their position on camera. I already use something like that for rendering.
  • Hm, yeah, the orientation checks the X/Z axis - I can add an option to check X/Y instead.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ooh that'd be great!
Sign In or Register to comment.