[SOLVED] How to make several objects animate/events occur simultaneously?

Started by Fitz, Wed 13/04/2011 08:26:15

Previous topic - Next topic

Fitz

So I'm trying to script the following situation: when the character enters a certain area of the screen, an NPC jumps out. The character goes EEEK!, trembles, turns around, goes away and changes his mind about fulfilling his mission - while the NPC still growls behind him. The problem is, each event plays out in sequence instead of several events occuring at the same time. The NPC jumps out, performs the "angry mode" animation, freezes, the character says eek, THEN trembles, then turns around goes away - leaving the perfectly still NPC behind him.

Is there a way to make it look better?

I'm doing this via "Stand on hotspot" - when the character walks onto it, it triggers off the event.

I need:
1. The NPC to jump out and act all scary for as long as I tell him to.
2. The character react with only a slight delay - say, 20 cycles - by trembling AND going EEK at the same time (I'm guessing SetView might work here?), turn around, walk away and rethink his life - with the NPC still going berserk behind him.
3. The NPC to calm down and retreat - going back to his usual mode of animation. Is there a "go back to previous state" command for that or do I do it via SetView, too?

Please note that I made one of the NPC's (a swarm of bees) an object instead of a character - reasoning that it's not a person, not really one entity, even. Does that make scripting the whole event more difficult/easier or is it all the same?

Khris

You can animate Objects and Character non-blocking, i.e. their animation will run in the background. Just use the eNoBlock parameter.
If you call this:
Code: ags
  cNPC.Animate(...eNoBlock);
  oDiscoLights.Animate(...eNoBlock);
  player.Animate(...eBlock);

all three animations will start at the same time and block the game until the player's has finished.

To make them say something and animate at the same time, use SayBackground.

To delay an animation (say you want a blocking action like talking and midway through that animate something else) you can use a standard frame as the loop's first frame and set a huge delay for it, like several seconds.

Fitz

Thanks, that fixed everything :)

A little additional question, though. I'd like to make him walk backwards, as if backing out rather than turning around (never let the enemy out of sight!) - but the regular cCharacter.Walk doesn't have the eBackwards option. Should I use cCharacter.Move combined with cCharacter.Animate or is there some simplier way to do it, like temporarily re-setting the Walk view to a different loop, which would be flipped horizontally to imitate walking backwards when in fact he'd be walking forwards?

Khris

Yep, these two are the available possibilities, short of doing it completely by hand. Whatever floats your boat. If you do it using .Walk you'll need a second view though; walking always uses loops 0-3.

SMF spam blocked by CleanTalk