Animating A Character...Robot Sentry

Started by harmonicapress, Wed 28/08/2013 00:25:40

Previous topic - Next topic

harmonicapress

I can put another character (aside from the main character) in a room, I even got him to talk and to stop me with a "HALT" every time I try to open the door he is "guarding", but how would I make my robotic character do something like pace back and forth across the screen. I made a robot sentry with all of the views he needs for full motion, and I've placed him in the room, but he just sits in one spot. How can I make him repeat a sentry pattern? I have been skimming the tutorials and the closest answer I could find featured timers but it was only explained in the context of Mr.Donatello's speech. I realize the answer here will be fairly long and complex, a point to a previous forum page or the right Youtube tutorial will suffice. Thanks all.
UPDATE
I also tried this (see code), and got the robot(clark) to pace, but now I have no mouse cursor??? Clearly their is a cleaner, correct way to do this. Please help.

function room_RepExec()
{
cClark.Move(108, 96, eBlock, eWalkableAreas);
cClark.Move(202, 94, eBlock, eWalkableAreas);
}

Gilbert

Quote from: harmonicapress on Wed 28/08/2013 00:25:40
but now I have no mouse cursor???
That's because when you use eBlock in the NPC's movement code you lose control of your character while he's still walking.
A suggested way is to check in room_RepExec() that when the NPC is no longer walking, make him start to walk again (with eNoBlock).
Something like(not tested):
Code: ags

function room_RepExec()
{
  if (!cClark.Moving){ //if he's no longer walking, make him walk
    if (cClark.x<120) cClark.Move(202, 94, eNoBlock, eWalkableAreas); //Move to right if he's on the left
    else cClark.Move(108, 96, eNoBlock, eWalkableAreas); //Otherwise move to left
  }
}

Lewis

Is there any reason why you're using Character.Move instead of Character.Walk? The latter should automatically animate through the walkcycle too, which makes things a lot easier.
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

SMF spam blocked by CleanTalk