Forum rules - please read before posting.

NPC Headturn - tracking player when he moves

Hello all!

As the title suggests, I'd like to know if there's a feature baked into AC that allows me to set head positions (Left/Right/Up/Down, Center, etc.) for an NPC that will update/track the player's movement/position.

I've tried accomplishing this with Triggers and Variables, but it becomes messy due to my desire to add random animations as well.

Is there something built into AC 2D, or do I need to set it up with triggers and variables?

As always, I appreciate any documentation, tutorials, or third-party scripts.

Thank you all, and have a great day!

Comments

  • edited February 2

    It's possible - both 2D and 3D characters support head-turning, though it's a lot easier in 3D.

    With 2D, you'll want to use a separate layer to animate the head - so that it can be animated independent of the body. The specific workflow depends on your Animation engine, however - which are you using?

    The best resource for this is the "Player prefab: 2D head-turning" package on the Downloads page. This offers two alternative Player prefabs from the 2D Demo - for Sprites Unity and Sprites Unity Complex. If you need guidance after checking them out along with the Readme, let me know which you're going with.

    Once a character has been set up for head-turning, the Character: Face object Action can then be used to control it.

  • I'm using Sprite Unity as the Animation Engine. Essentially, what I want to accomplish is having a taxidermy deer mounted on the wall. When your sanity/HP drops below a certain number, I'd like it to follow you around the room (head turn based on character position) and then trigger various animations with Variable: Check random number. Currently, I have it partially working with variables and triggers, but I'm encountering issues with the actual turning, as it also controlled by triggers. Additionally, I have actual turn animations; it's not just a single frame (L, R, U, D). Thank you for your assistance. I'll explore the headturn prefab. If you have any other suggestions on how to achieve this, I would greatly appreciate it.

  • If you already have the logic to turn their head with Triggers, it may not even need to be an NPC, in that case - just an Animator.

    Rather than playing animation names directly as part of the Trigger, though, use an Int parameter - set to e.g. -1 when looking left, 0 when forward, and +1 when right. You'll then be able to account for it in your Animator's transitions when playing back different animations - removing the need to separately keep track of which direction they're facing.

  • Worked like a charm. Thank you very much! I added a Link Variable to Animator and Set triggers. Thank you again. Have a great week end!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.