Two characters walking simultaneously?

Started by Monsieur OUXX, Tue 02/09/2014 17:17:33

Previous topic - Next topic

Monsieur OUXX

Apprently, after all these years, I still have issues managing non-blocking events.
In the code below, why does "player" walk THEN r walks??? (and player says "wut?" at the same time as r starts walking)  Shouldn't they be walking simultaneously?


Code: ags

    //"WaitSeconds" is a conveninent function from the Tween module but I could as well do "Wait(200);"

    // Note: this code is triggered by an Interaction event on "r".
    r.SetWalkSpeed(r.WalkSpeedX*3, r.WalkSpeedY);
    Wait(1);
    player.Walk(player.x - 100, player.y, eNoBlock);
    r.Walk(r.x - 200, r.y, eNoBlock);
    WaitSeconds(2.0); 
    player.Say("wut?");
 

AnasAbdin

I've noticed that the "Say" command forces the character to stop walking. So what your code should do is let both the player and r walk towards the desired positions simultaneously for "2 seconds" then player should stop at where he reached in 2 seconds (even if midway...) and start talking.
If you want to keep a character walking while talking try using the "SayBackground" command instead.

Khris

Are you saying the player walks 100 pixels to the left, and only after they got there, r starts walking?
What happens if you remove lines 8 and 9?

Monsieur OUXX

@anasabdin I'm just trying to make them walk simultaneously -- the "Say" instruction is just for after they finish walking.

Quote from: Khris on Wed 03/09/2014 13:15:27
Are you saying the player walks 100 pixels to the left, and only after they got there, r starts walking?
Yes, that's what happens. I'll try your suggestion.
 

Khris

eNoBlock is the default anyway, does anything change if you call .Walk() with just the coordinates?

AnasAbdin

First of, if not: cover the entire room with a walkable area and see if this still happens. I did see weird stuff happening due to weird walkable area shapes.

Monsieur OUXX

There is something very weird: player still walks first if I put the r.Walk instruction BEFORE player.Walk
They are both on a walk area.
I'll try to fiddle with eBlock and eNonBlock, but I'm quite pessimistic.
 

Khris

What happens if you send one of them using eNoBlock, then the other using eBlock?
Do they walk as expected on their own?

Stupot

I could be wrong but, what if r.Walk was blocking. As long as player starts walking first, he should carry on walking when r starts right?
Then you wouldn't need the waitseconds command, he would just way 'wut' when he reaches his destination.

Monsieur OUXX

Quote from: Stupot+ on Thu 04/09/2014 10:52:19
I could be wrong but, what if r.Walk was blocking. As long as player starts walking first, he should carry on walking when r starts right?
Then you wouldn't need the waitseconds command, he would just way 'wut' when he reaches his destination.
I agree. But none of those combinations seem to work.
I suspect something fishy, like another piece of code somewhere else (in RepExec) doing a blocking r.Walk in my back.
 

Monsieur OUXX

Alright so I never managed to find out what's wrong in my script, but it's definitely not something wrong with AGS, or with this specific portion of script. The issue is more tricky and lies somewhere else (as I said, probably in RepExec).

Therefore, no need to investigate further here. I made a dirty hacky workaround using "Character.Follow".
 

SMF spam blocked by CleanTalk