Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Yeah, it works if its just a pop-up text with single line, but i want it to be like a conversation then have choices like "Keep talking" , "Get quest" , "Don't want to talk" If you get what i meant.
Copy link to clipboard
Copied
And what are you expecting someone to do for you to realize what you want? Create a movieclip that has the features you want and assign keyboard controls for the different items you list if that is your intention.
Copy link to clipboard
Copied
Nope, im trying to find if someone has a sample link how to do it, not asking if someone can do it for me... 😕
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now