Scripting help for FollowCharacter

Started by Imhotep, Sun 30/07/2006 12:41:31

Previous topic - Next topic

Imhotep

I have used

Ã,  Ã, cShoe.FollowCharacter(cEgo,FOLLOW_EXACTLY,0);

and it works. And cEgo is animated at walking like it's view. But cShoe is only a static sprite, which I like to be animated by walking too.

Thankyou and Greetings from Germany

Khris

Did you set up proper walk cycle frames in cShoe's Normal view?
What happens if you make cShoe the player character and walk around?

(Kennst Du daujones.com?)

limeTree

When Shoe walks normaly,does it move as a static sprite,or it has a complete animation?

Imhotep

Yes, cShoe has cycle frames for 8 directions like cEgo has. And it is compledly animated, when walk around as the player character. It is also animated, when

   cShoe.FollowCharacter(cEgo,10,10);

is used.

(@KhrisMUC: Hab grad mal geschaut, LOL)

Khris

That's weird. I've never used FollowCharacter with the FOLLOW_EXACTLY option, but there's a workaround using repeatedly_execute to make sure Character.X, Character.Y and so on stay the same for both characters.

(Es gibt einen Imho-tep bei daujones, deswegen hab ich gefragt :))

GarageGothic

if setting the X and Y coordinates in the repeatedly_execute, make sure to also set the followcharacter's loop and frame accordingly, since he won't animate by himself.

Imhotep

Well if using

   cShoe.x=cEgo.x;
   cShoe.y=cEgo.y;

in RepEx it's not better. cShoe even begins to flicker. And I'm not sure how to animate it, because it should use its walk-cycle-frames and not a specified loop of a view like cShoe.Animate will do.

Alynn

Crazy random thought... is cEgo block moving? I've never played with the follow character, but it would make sense that while it may still follow, it may not animate if ego is blocking...

Like I said random thought, never used follow char, so I may be completely wrong.

Imhotep

That was a good idea to explain, but I don't think that cEgo is blocking because it is player character. And if cShoe follows it with distance both are animated like they should.

Imhotep

Hmm, I thought it would be easier to solve this problem. I'm trying around but it's not working...

Noboby with experience in this?

Gilbert

Well, two questions here:
1. Where did you put the FollowCharacter() line ? Make sure that you only need to call it once and then the character will follow the player and animated as instructed until the function is called again. If you call it repeatedly (like in repeated_execute() say for example) it may happen that each time the function is called the character got reset so the sprite looks like it's static.
2. If you used the modify x, y- coordinates method, make sure you DON'T do it together with FollowCharacter(), since modifying the coordinates while a character is moving (using FollowCharacter() makes him move) is not recommended and can cause problems.


My suggestion is, try using the FollowCharacter() method first, and like in 1. mentioned, make sure that the function is called only once (like putting it in "player enters room" say for example) and it's not called repeatedly. Normally, you don't need to manually mess with his coordinates unless you want to do more advanced stuff.

Imhotep

I put it here:

    // script for Room: Player enters room (after fadein)
   cShoe.FollowCharacter(cEgo,FOLLOW_EXACTLY,0);

Have I to add another command for the animation?

Gilbert

Well I'd checked it, and indeed got your problem.
It's a know issue actually.

A workaround is to add this to the script (if you had already created a repeatedly_execute_always() function, just copy the 2 lines of codes):
Code: ags

function repeatedly_execute_always(){
  cShoe.Loop=cEgo.Loop;
  cShoe.Frame=cEgo.Frame;
}


However, this is not perfect, seems that there's still a 1 frame lag on the cShoe frame, just sort of working.

Imhotep

Hurray, that's the way I wanted it! Okay the lag is still there, but maybe the FollowCharacter() will be fixed in future.

Thanks to all of you.

gypsysnail

Hi I know this thread was from a little while back but I am also going to have a small character follow my character for the most part of the game. I just wonder what happens - that I have my main character having 7 total frames for her walk in every direction and the small follow character having only 2 frames - is this ok? If not, what must I do? Help much appreciated for this newbie :).
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

SSH

Well, most of this thread is irrelevant if you want to just have one character follow another around. The stuff discussed here is if you want to do something complicated like use a character for a shadow which must animate exactly the same as the main character. Your thing needn't worry about all this, just run FollowCharacter and forget about it!
12

gypsysnail

Ok that is easy. The problem is also, how can I edit the script to have the bird sit on the character's shoulder whenever the player stops the character's walk any time? If someone knows how to tweak this, that would be great!
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

SSH

Good question and not simple. But here goes:

First, you need to detect when the player is moving, so you'll need to check player.Moving in the repeatedly_execute. Then you need to make the bird move non-Blocking to the correct position for the shoulder of the player character. You may also need to make sure that the baseline of the bird is set to more than the baseline of the player (cBird.Baseline=player.Baseline+1 in rep_ex)

12

gypsysnail

Hi SSH, thanks for the advice. I have tried, but I think I need further help as I am so new to this kind of scripting, I have tried to put the stop moving script in following the manuals help but I just don't understand the rules of the programming language (just yet) and I tried putting it in and going to test game but got the error that there was a problem in that line where I put the stop moving in. I put it under the repeatedly execute follow character part. If one of you can help me with the stop moving one so bird can sit on the characters shoulder, that would be great. I do understand the baseline somewhat, but its all a bit hazy to me at this point.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Khris

1. Always post the exact error something, not "it said smth like" or "there was an error". AGS tells exactly what's bothering it most of the time. Make use of it.

2. Show us the code you use, there's not much we can do without it apart from guessing what went wrong.

SMF spam blocked by CleanTalk