FOLLOW_EXACTLY-related question

Started by thom0512, Mon 27/07/2009 01:36:46

Previous topic - Next topic

thom0512

Hello everyone.  I have read through the manual and performed numerous forum searches but haven't found anything that has helped me.

I want a non-playable character to follow the playable character, but I want it done in a fashion so that the NPC will be "following the leader" and matching their every move, but doing so a moment or two later (so no waiting around, no moving to a random location close by the playable character, etc).  FOLLOW_EXACTLY has sent me in the right direction, but it's still not helping because no matter what value I input, overlapping of characters still occurs.  I hope this makes sense; any help would be greatly appreciated.

Ethan D

Have you tried the FollowCharacter function?

monkey0506

#2
Quote from: The manualThere is also another special use for this command. You can pass the special value FOLLOW_EXACTLY as the DIST parameter rather than passing a number. If you do this, then CHARID will always remain at exactly the same X and Y co-ordinates as CHARTOFOLLOW. This might be useful for effects such as a temporary halo over the character and so forth.

FOLLOW_EXACTLY is part of the Character.FollowCharacter function Float. The problem is that with FOLLOW_EXACTLY the two characters will share the same (X, Y) co-ordinates. Therefore the overlapping is intentional.

To make the character follow "a moment or two later" you need to set the DIST parameter to something OTHER than FOLLOW_EXACTLY, and use the EAGERNESS as well:

QuoteDIST sets how far away from CHARTOFOLLOW that CHARID will stand. If DIST is 1, they will try to stand very close; if DIST is for example 20, they will stand about 20 pixels away.

EAGERNESS sets on average how long the character will stand around before checking if he needs to move again. Setting this to 0 means that he will always be on the move until he reaches CHARTOFOLLOW; setting this to 99 means that he will pause and think for a while on route. Values in between specify different lengths of idle time

Edit: I corrected the parameters. I was a bit tired when I posted last night. FOLLOW_EXACTLY applies to the DIST parameter.

Khristian Cammilleri

You Should Use FollowCharacter

Code: ags
Character.FollowCharacter(Character* chartofollow, optional int dist,
                          optional int eagerness)


Pass CHARTOFOLLOW as null to stop the character following

DIST sets how far away from CHARTOFOLLOW that CHARID will stand. If DIST is 1, they will try to stand very close; if DIST is for example 20, they will stand about 20 pixels away.

EAGERNESS sets on average how long the character will stand around before checking if he needs to move again. Setting this to 0 means that he will always be on the move until he reaches CHARTOFOLLOW; setting this to 99 means that he will pause and think for a while on route. Values in between specify different lengths of idle time.


The FollowExactly Command Is useless if  you want to make a character to follow your player ::)
PizzaNostra!

monkey0506

FOLLOW_EXACLY is not useless, it does exactly what the manual says. The two characters will have exactly the same (X, Y) co-ordinates. This can be useful if it's what you want. What's useless is saying a valid function is useless just because of user error and/or failure to read (or at least understand) the manual which documents proper usage.

dbuske

I add the following script to the room script and I get an error message.
cMuffy.FollowCharacter(cDanny);
It says unexpected error with cMuffy.
Muffy is a dog who I want to follow Danny most of the time except when I script to make her save the day.
What if your blessings come through raindrops
What if your healing comes through tears...

Matti

Yeah, so what does the code look like and what does the error message exactly say? It seems you didn't put the command inside any function (like the rep-exec.).

Also, don't dig up old threads that have nothing to do with your question.

dbuske

The command was exactly as I wrote it. 
Here is the error message:

Message                                                          room  room1.asc                                      line 2

Failed to save room1.crm; details below
Error (line 2): parse error; unexpected 'cMuffy'

I don't know what your guess said.  I am new to scripting.
What if your blessings come through raindrops
What if your healing comes through tears...

Matti

Quote from: dbuske on Fri 19/11/2010 16:01:52
I don't know what your guess said.  I am new to scripting.

Where exactly did you put that line? Make sure it's within the room load or the rep-exe or any other function. You know, within { and }.

dbuske

I put it in the room script of room1 called forest walk.
What if your blessings come through raindrops
What if your healing comes through tears...

Sslaxx

Quote from: dbuske on Fri 19/11/2010 16:09:07
I put it in the room script of room1 called forest walk.
Copy and paste the script here, please.
Stuart "Sslaxx" Moore.

Matti

Within the room script it has to be within a function.

If it looks like this

Code: ags

// room script

cMuffy.FollowCharacter(cDanny);


.. you get an error message (and should definitely do the tutorial).

If it looks like this it should work (well, not really since the command would be called every game cycle and thus never start - but you shouldn't get any error):

Code: ags

// room script

function room_RepExec(){

cMuffy.FollowCharacter(cDanny);

}


Yeah, what Sslaxx said, show us the script.

dbuske

Heres the script:

cMuffy.FollowCharacter(cDanny);
What if your blessings come through raindrops
What if your healing comes through tears...

Sslaxx

Quote from: dbuske on Fri 19/11/2010 16:19:45
Heres the script:

cMuffy.FollowCharacter(cDanny);

Are you saying that this is all the code you have done in this room? I mean the script for the entire room.
Stuart "Sslaxx" Moore.

dbuske

Looks like a couple of guys fooling the new guy
What if your blessings come through raindrops
What if your healing comes through tears...

Sslaxx

Quote from: dbuske on Fri 19/11/2010 16:26:39
Looks like a couple of guys fooling the new guy
Can the attitude, mate. Nobody's trying to fool you. Follow Matti's advice, take a look at the tutorial.
Stuart "Sslaxx" Moore.

dbuske

I will go elsewhere.  I don't need to be made fun of.
What if your blessings come through raindrops
What if your healing comes through tears...

Matti

#17
Nobody is making fun of you (yet), but if your room script really just contains that single line, then you should do the tutorial.

And pay close attention to the events pane:


Khris

dbuske:
You have already acquired a record here of doing stuff that's frowned upon; within not ten posts you have asked several extremely basic questions that clearly show you didn't bother to read the tutorial that comes with AGS (which in turn means you didn't read or follow the rules of this forum), you also didn't go back to these topics, not even to mark them as solved, and you announced a game more than prematurely, again violating the forum rules in the process.
These forums are paid for by the guy who created the free engine you're using, and we help you here for free in our spare time. Keep that in mind in the future, if you please.

Regardless, what people posted here was in no way meant to make a fool out of you. For one thing, not all of us realized immediately that the one line was all you had in your room script, secondly you kind of stubbornly posted what you did several times without addressing anything that e.g. Matti replied.

These forums are extremely friendly and helpful towards newbies in general and I'd really be careful not to waste that right at the beginning.


With that out of the way, open the first room where Muffy is supposed to follow Danny, click the lightning bolt icon as shown in Matti's picture, then click on the line marked blue and finally on the ellipses button.
AGS creates a function called something like room1_AfterFadein(). Put the command inside the curly brackets that mark the beginning and end of the function body.

Next time you test run the game, as soon as you enter that room and the background has faded in, AGS calls that function and all the commands inside are executed, i.e. the one you just added.

dbuske

Thanks for the help Matti.
I am slowly figuring out the scripting.  Pointing me to the event button really helped.  Being new to all this, I just didn't understand even how to start doing scripting.
I am making good progress now.  I even got my dog character to follow the main playing character automatically.
Now I need to learn how to do the dialogs, music and sound.
If I want to ask for help for making all the dog character views (drawing them, front, back, sides), which forum do I do that.  Meaning getting someone to point me to maybe an already done dog character.
What if your blessings come through raindrops
What if your healing comes through tears...

SMF spam blocked by CleanTalk