Animating non-playable characters

Started by Kamileon, Fri 13/06/2014 05:05:13

Previous topic - Next topic

Kamileon

When the player enters room 2, I want a bird to fly in and land before the player has the option to move. The bird then talks to the player, before flying off again.

Is there a way to code the movement of the bird or would it be simpler to do with a cutscene?
It's not who I am underneath, but what I do that defines me.

Vincent

This could be one of the worst ways to do it.
but maybe it could inspire you

Code: ags

bool first_time = true;
function room_AfterFadeIn()//room 2
{
  if (player.PreviousRoom == 1 && first_time)
  {
     StartCutscene(eSkipESCOnly);
     Mouse.Mode = eModeWait; //you can change this graphic, probably with no image at all
     if (!cBird.Moving) {
     if (cBird.x < 100) {
      // if the bird is on the left hand side of the screen,
      // start it moving towards the right
      cBird.Walk(400, cBird.y, eBlock, eAnywhere);
      cBird.Say("Hello There");
      EndCutscene();
      cBird.Walk(0, cBird.y, eNoBlock, eAnywhere);
      mouse.Mode = eModeWalkto;
      first_time = false;
   }
  }
 }
}


Kamileon

The movement of the character is working really well; thanks for the help Vincent. :smiley:
There is just one thing I need to add to the script, but am unaware of how to write it - how do I make the character leave the room? I tried using edges but didn't seem to work.

Code: ags
function room_LeaveBottom()
{
  cBird.ChangeRoom(3, 155, 155);
}
It's not who I am underneath, but what I do that defines me.

Ghost

#3
Edges are only checked when the player character moves over them- your command would be triggered when the PLAYER leaves via the bottom edge.

A simple way is to use the Walk command with the eAnywhere parameter. Make a new walk command and set the y destination to higher than the room's height (in a 320x240 game, set y 0 260). This allows you to have the bird move OFFSCREEN (that's safe and a rather common technique).

After moving, you can call cBird.ChangeRoom(wherever).

Kamileon

It's not who I am underneath, but what I do that defines me.

SMF spam blocked by CleanTalk