Hi,
If a character interacts/looks etc and it's during player walking the player should cease walking, even after interacting/looking until commanded to do...
At the moment it kind of looks silly.
Would like an 'if player walking' condition.. Then stop player temp. from walking.
Cheers
Quote from: Slasher on Sat 08/08/2020 08:51:21
Would like an 'if player walking' condition..
Not sure if this is what you asking about, but there's Character.Moving property that is "true" when character walks or moves with Move command. There's similar property for an Object.
hi, this makes the character arrive at their destination to perform the action and can be interrupted
if (Verbs.MovePlayer(x, y)) {
Quote from: zeta_san on Sat 08/08/2020 16:46:44
hi, this makes the character arrive at their destination to perform the action and can be interrupted
if (Verbs.MovePlayer(x, y)) {
That's specifically for when using the Tumbleweed template...
I would use this to get that effect... may not be elegant but I just tried it and it will work;
To stop a moving Object/Char
cEgo.Move(200, 100, eNoBlock, eWalkableAreas);
if(cEgo.Moving==1)
cEgo.StopMoving();
This works to stop a moving character or object - However the Character is not 'moving' in your example... but is 'walking'!
To stop a walking Character
int CharX=cEgo.x; int CharY=cEgo.y;
Wait(1);
if ((CharX==cEgo.x) && (CharY==cEgo.y))
Display ("Wasn't Walking!");
else {
cEgo.Walk(cEgo.x, cEgo.y, eNoBlock, eWalkableAreas);
Display("Was Walking, but is not now!");
}
- Which stores the Characters x/y position on the screen, then waits 1/40th of a second, then checks for any change to either of those values (meaning it is walking). If there is a change, then make the character 'walk' to the 'current location' (effectively halting the character from walking - i.e: 'cancelling' the prior 'walk' location that it was going to and setting that to where it already is)
Quote from: ToeKnee on Mon 17/08/2020 17:57:34
To stop a moving Object/Char
cEgo.Move(200, 100, eNoBlock, eWalkableAreas);
if(cEgo.Moving==1)
cEgo.StopMoving();
This works to stop a moving character or object - However the Character is not 'moving' in your example... but is 'walking'!
Character.Moving and
Character.StopMoving also work with the
Walk command.
From the manual:
QuoteExample:
cEgo.Walk(125, 40);
while (cEgo.Moving) Wait(1);
will move EGO to 125,40 and return control to the player when he gets there.
Also, you don't have to do "if(cEgo.Moving==1)". Simply doing "if (cEgo.Moving)" is enough.
Quote
cEgo.Move(200, 100, eNoBlock, eWalkableAreas);
if(cEgo.Moving==1)
cEgo.StopMoving();
Laura, the manual says that but it does not work in gameplay once the Character is moving.
I just tried it again using the Moving and Stop Moving commands when you click on anything whilst the character is moving and it will
not stop it.
My code works but those commands do not interrupt the normal 'walk' command that AGS has internally to move a character (probably has it's own blocking style)
Cheers. Tony
Quote from: ToeKnee on Wed 19/08/2020 09:21:09
Quote
cEgo.Move(200, 100, eNoBlock, eWalkableAreas);
if(cEgo.Moving==1)
cEgo.StopMoving();
Laura, the manual says that but it does not work in gameplay once the Character is moving.
I just tried it again using the Moving and Stop Moving commands when you click on anything whilst the character is moving and it will not stop it.
I have the following lines in my script and it works perfectly fine when the character is walking:
function hLamp_Interact()
{
if (cLadyW.Moving) cLadyW.StopMoving();
cLadyW.SetWalkSpeed(1, 1);
}
You must be doing something else that's interfering with it, because the commands work exactly as expected (otherwise the game would crash, because you can't change walk speed while a character is moving).
I imagine that player.StopMoving() will always work but depending on where exactly you put it, might not get called during a blocking walk.
I put it in repeatedly_execute_always and it stopped the player perfectly fine during a standard blocking walk and a hotspot's walkto point approach (which is probably the same as a blocking walk internally).
QuoteYou must be doing something else that's interfering with it
Yep, on re-checking the Stop Moving command was triggered on a Hotspot that has a 'WalkToPoint' set on it
- if I
clear the WalkToPoint (0,0) - then the Character stops. Otherwise it (of course) keeps moving/walking to the Hotspot if I interact with it whilst character is moving.
Quote from: ToeKnee on Wed 19/08/2020 10:00:55
QuoteYou must be doing something else that's interfering with it
Yep, on re-checking the Stop Moving command was triggered on a Hotspot that has a 'WalkToPoint' set on it
- if I clear the WalkToPoint (0,0) - then the Character stops. Otherwise it (of course) keeps moving/walking to the Hotspot if I interact with it whilst character is moving.
Ah, that explains it, of course if the walk command is blocking then a workaround (such as using repeatedly_execute_always like Khris suggested) is needed. Glad it made sense in the end!