Skip to main content
Participant
January 27, 2013
Answered

Enemy & NPC like conversation

  • January 27, 2013
  • 1 reply
  • 1273 views

Hello, I was wondering how make an enemy that follows the character around, but the enemy is just in one position (horizon position let say) so it just follow the character left and right.

also is there any example or better explanation how to make a RPG npc like mechanism when character come close to it or hit key it will start talking.

Thank you.

This topic has been closed for replies.
Correct answer Ned Murphy

Nope, im trying to find if someone has a sample link how to do it, not asking if someone can do it for me... :/


Try this: http://forums.adobe.com/thread/1140139?tstart=30

1 reply

Ned Murphy
Legend
January 27, 2013

For either case you want to know about, you need some form of continuous monitoring to keep track of things and make changes when certain changes occur.

To have the enemy follow the left and right movement of the character, any time the character moves you need to have the enemy horizontal property (x) changed to be equal to it.

To have a dialogue open due to proximity of two objects you need to constantly monitor the distance between them and define a limit that when exceeded will trigger the dialogue.

TylooASAuthor
Participant
January 27, 2013

Hi, thank you for your reply.

I kind of worked out the enemy follow character:

if(char.x < enemy.x){

enemy.x -= enemySpeed;

{

thats how i did it, i know its not the best way of doing it but for beginner i think its good :/ somehow.

On the dialogue can you give an example how to do it? I'm planning to trigger it when a key is pressed instead, and character will not able to move while the character is still talking to the npc.

Ned Murphy
Legend
January 27, 2013

If yiou are currently using a keyboard listener to control movement then you just need to include a text within the existing event handler function to check if the key that was used is the key to invoke the dialogue and if so, make the dialogue element appear.