animate character

Started by dude_r005, Thu 09/11/2006 12:10:59

Previous topic - Next topic

dude_r005

hello I have a simple question.
I recently started programming a adventure game with ags.

during scripting I a error accured:

I tried to do this:

object 5
conditional (if inventory Item was used) : 8
quick animation (view 16, loop 0, speed 12)
change obejct view : 3
animate object: 5

that works fine, but I wanted to wirte it as a script, so that the character displays a speech, when any othe item was used.

I got so far:

if (character [GetPlayerCharacter()].activeinv ==  8 ) {
 
SetCharacterView (EGO,16);
AnimateCharacter (EGO,0,12,0); (last value is for boolean False)
ReleaseCharacterView (EGO);

SetObjectView (3,15);
AnimateObject (3, 0, 1, 1);
DisplaySpeech(EGO,"Oh no the cable went out! Must be the damn antenna again.");



}
else {
DisplaySpeech(EGO,"I don't wanna use this with my TV.");} 



But now the character doesn't do the animation anymore. what is wrong??
the object animation works fine and the message is displayed. I don't see the error. can anybody help?
I already tried a lot.

SSH

Because you release the character view straight away, the animation stops. Do you really want the animation of the character not to block?
12

dude_r005

I have to release the characterview right away.

I try to describe what I was trying to do a little more detailed:

The character has a remote control(inv item 8). if it is used on the tv (object 5) the character shall move his arm and "press" the remote control. after that the tv shall bring a picture.

this works fine if I use the predefined help-funkctions. but I want an own script so, that I can modify some GlobalInts and use some "else if's" and elses.


If I don't release the characterview my buddy walks around using the remote all the time. If I release it later (after the object animation is finished), it stays as before:
the object animates, the character walks normal, but he doesn't move his arm and doesn't press the remote control.
I apollogize for my bad english

dude_r005

ok, I found the resolution. 




if (character [GetPlayerCharacter()].activeinv == 8){
 
SetCharacterView (EGO,16);
AnimateCharacter (EGO,0,5,1);
Wait(18);   // <---this is important. Without it the animation can't be seen
ReleaseCharacterView (EGO);


SetObjectView (3,15);
AnimateObject (3, 0, 1, 1);

DisplaySpeech(EGO,"Oh no the cable went out! Must be the damn antenna again.");


int blubba;
blubba = GetGlobalInt(4);
blubba++;
SetGlobalInt(4,blubba);}



else {
DisplaySpeech(EGO,"I don't wanna use this with my TV.");}






Khris

That's the equivalent of making the animation blocking, the only difference is that you won't have to calculate or guess the Wait()-param... ;)

dude_r005

hmm, blocking...this might even be better. How is this working? I found out, that my solution can lead to difficulties if yo want for example let your character move to a certain location. can you paste an example? it would be very helpful. thx for your help and hints

Khris

The new code, from the top of my head, would look something like this:

player.LockView(16);
player.Animate(loop, speed, eBlock, eOnce);Ã,  // loop and speed being replaced with actual numbers, of course
player.ReleaseView();

This will play the animation, then revert the view back to the character's normal view holding his standing frames and walk-cycle.

eBlock means that the script will pause until the Animation has finished. AFAIK, eOnce is the default option and optional, so you don't have to include it.

And btw., if you're new to AGS, don't bother learning the old code. Make sure you have the latest version (2.72).

dude_r005

hmm...thanx a lot. I am using v.261. I guess I have to check out the new version and get familair with this way of scripting. thanx anyway

SMF spam blocked by CleanTalk