Making character come back after walking off screen edge

Started by paolo, Fri 14/09/2007 16:39:48

Previous topic - Next topic

paolo

Apologies if this has already been asked and solved somewhere else, but I haven't found it in this forum if it has.

One edge of one of my rooms is intended to be a dead end, except it doesn't look like it in the background image. So, when the player walks off that edge, I want to make him say that it's a dead end and then walk back again.

What I have coded up isn't quite right, as it seems as though only the first two frames of the walk cycle are played as the character comes back, giving him a juddering, skipping movement.

My script for "Walk off right screen edge":

   cMyCharacter.SayBackground(Game.GlobalMessages[504]);
   cMyCharacter.Walk(141, 146);

Game.GlobalMessages[504] says "It's a dead end" (it's a global message because I'm using it in more than one place) and (141, 146) is definitely within the walkable area and is back inside all edges of the screen.

I want to use SayBackground so that the character comes straight back without the user having to click or press a key to make him do it.

Thanks.

EDIT: Is the problem that, while the character is walking back to the edge, he is still over the edge and so this script keeps getting called again and again, meaning that only the beginning of the walkcycle is played? If so, what is the correct way of doing what I want to do?

Mazoliin

If you use a region to start the walking-of-edge-thing, you could use region[X].Enabled to get it to disappear when the character walks back, and then use the same code to make the region reappear when it's done.

Khris

Does it work if you use Say instead of SayBackground?

Btw, using that interaction shouldn't be a problem because it says "walk off", not "be outside", so I doubt it's called repeatedly.

Ashen

Actually I think it IS called repeatedly, as long as the character is beyond the edge coordinate - something like that, anyway, since when I try it the character walks in place, as if the Walk command is repeating. Try making the Character.Walk command blocking, and see if that helps.

Using Say instead of SayBackground shouldn't mean the player has to press a key to make him walk, unless you've set speech to not automatically time out (SetSkipSpeech(3) or 'no autoremove' from the General Settings drop-down). It should just make them wait a little while, which they CAN skip with mouse/keypress if they want to.
I know what you're thinking ... Don't think that.

paolo

Quote from: Monkey Entertainment on Fri 14/09/2007 16:56:13
If you use a region to start the walking-of-edge-thing, you could use region[X].Enabled to get it to disappear when the character walks back, and then use the same code to make the region reappear when it's done.

Thanks for all the suggestions. In the end I used a region, as Monkey Entertainment suggested. I didn't need to turn it off as the character walks back as the event is triggered only when the character walks onto the region. There is a separate event for the character being in the region.

I've used SayBackground deliberately because I want the character to come back immediately rather than waiting for the player to click or press a key (which is how I have the game set up). This works fine with what I have done.

SMF spam blocked by CleanTalk