Forum rules - please read before posting.

(2D) Push Away NPC

edited February 2023 in Technical Q&A

Hello. I'm working on a 2D game with 2 sides walking left and right. I'm looking for a way to push an NPC away from the character whenever he gets close.

I've tried both Actions Object: Transform and Object: Animate but it only push the NPC to the determined direction like -5 on X axis whether the NPC facing.

I'm using frame flipping for custom animations. So the only way I can do it is not using flip animation and make 2 different "pushed' animations for 2 sides. But I also have to do all other custom animations.

Is there a better way to push the NPC away?

Thank you.

Comments

  • Not exactly the same situation, but I've had good luck emulating a "push" (in my case it was an action to row a boat) using "Object: Transform" with a custom curve and "Object: Animate" at the same time. It looks cool.

    In your case, maybe you could have two different triggers on either side of the NPC, each containing a transform to move the player to the opposite side?

    The animation could probably still be mirrored depending on how you want it to look. It will really depend if you just want the player to look like they are staggering backwards, or falling down, etc. I could see it working with mirrored animations depending on the art style.

  • 2 triggers on 2 sides make sense to me. I've never thought about it. Thanks a lot for the suggestion.

  • Welcome to the community, @Zinph.

    If this is more a case of wanting the NPC to walk out of the Player's way if they get too close, the NPC component has a Keep out of Player's way? option towards the bottom of their Inspector. Checking this then allows you to set a minimum distance that they can keep from the Player character.

  • It's like an interaction to push back the NPC so I can't use Keep out of Player's way.
    Btw, the engine is awesome for an artist with no knowledge of coding like me. Really appreciate you creating it.

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.