[SOLVED] Weird problem. eOnce plays twice

Started by isatche, Sat 26/09/2020 09:37:46

« previous - next »

isatche

Hello,
I want my character to take a hit and tumble while flying backwards.
The problem is, he tumbles while going back but tumbles again when he reaches the destination and then stops.
It annoys me to no end.

Here is the code:
Code: ags

//Grumpy rams Starman
oGrumpy.SetView(22); 
oGrumpy.Animate(0, 1, eOnce, eNoBlock);
oGrumpy.Move(420, 300, 1, eBlock, eAnywhere);
oGrumpy.Graphic = 27;


// Staman Tumbles
cStarman.LockView(21); //tumble animation

cStarman.Animate(0, 3, eOnce, eNoBlock);

cStarman.Move(350, 300, eBlock, eAnywhere);



Any ideas please?
Thank you!

Matti

You need to use eBlock when calling the animation, otherwise the animation and Move-commands will be called at the same time.

isatche

The animation and the move should be at the same time since he tumbles while moving.
The problem is, animation plays while moving and then plays again when the moving stops.

Slasher

#3
Where have you put the script?

Are you using collide script?

isatche

#4
Umm.. I am not sure what is a collide script?
The script is in a room.

Here is the whole thing if it helps...

Code: ags


function room_FirstLoad()
{
  cWildling.SetAsPlayer();

oLanding.Visible = false;

oGrumpy.SetView(17);
oGrumpy.Animate(0, 3, eRepeat, eNoBlock); // Idle animation

StartCutscene(1);

cWildling.SpeechView = 11;
cWildling.Say("Here you are!");
cWildling.Walk (527, 305, eBlock);
cWildling.Say("...");
cWildling.SpeechView = 18;
cWildling.Say("WHAT. IS. THAT?");

oLanding.Visible = true;
oLanding.SetView(16);
oLanding.Animate(0, 3, eOnce, eNoBlock);
oLanding.Move(344, 295, 1, eBlock, eAnywhere);

cWildling.Say("...");

oLanding.Graphic = 152;
cStarman.Transparency = 0;

cWildling.Say("...");


cStarman.Walk(415, 301, eBlock, eAnywhere);
cStarman.Say("Hello, I come in p...");
cWildling.Say("AAAAH!");

//Grumpy rams Starman
oGrumpy.SetView(22);
oGrumpy.Animate(0, 1, eOnce, eNoBlock);
oGrumpy.Move(420, 300, 1, eBlock, eAnywhere);

oGrumpy.Graphic = 27;

// Staman Tumbles
cStarman.LockView(21);

cStarman.Animate(0, 3, eOnce, eNoBlock);

cStarman.Move(350, 300, eBlock, eAnywhere);



cWildling.Say("GRUMPY! NOoo...");
oGrumpy.SetView(23);//Grumpy runs away
oGrumpy.Animate(0, 1, eRepeat, eNoBlock);
oGrumpy.Move(626, 228, 1, eBlock);
oGrumpy.Visible = false;

visible = 1;
cWildling.Say("...");
cWildling.Walk (480, 305, eBlock);
cWildling.Say("Is he alive?");

EndCutscene();
}



morganw

Do you just mean this part plays the animation twice?
Code: ags
// Staman Tumbles
cStarman.LockView(21);
 
cStarman.Animate(0, 3, eOnce, eNoBlock);

cStarman.Move(350, 300, eBlock, eAnywhere);

isatche

Correct.
Once when it's supposed to, while moving.
And it repeats the animation once more when moving stops.

I'll try and take a screen-grab later today so you can see what it looks like.
I might go around and use object instead of the character, but I am still curious why is it happening.

Slasher

You could double check if 'play next loop' in the view 21 is ticked..

isatche

There is only one loop in that view and "run the next loop..." is grayed out and unchecked.

Snarky

First, you seem to be missing an UnlockView after the animation, though I'm not sure whether SetView takes care of it. In any case, I would add that for consistency.

Then I'd start by commenting out the rest of the cut-scene. Does it still happen?
Then try commenting out the Move, and change the Animate to blocking. Does it still happen?
Then try commenting out the parts before the Animate. Does it still happen?

If you're left with just that one command and it still plays the animation twice, the problem must not be in the script.

isatche

Quoteyou seem to be missing an UnlockView after the animation
I want him to stay on the last frame until the player takes the action. He is knocked out and the player needs to revive him.

QuoteThen I'd start by commenting out the rest of the cut-scene. Does it still happen?
- Yes

QuoteThen try commenting out the Move, and change the Animate to blocking. Does it still happen?
The problem is, it repeats after the move is done. When I comment out the move, it plays once as it should be.
When I block the animation, it plays in one spot, then move while on last frame, then at the end of move it ends on the first frame of the animation and stays there?!

QuoteThen try commenting out the parts before the Animate. Does it still happen?
Yes, it does.

Here is the video: https://youtu.be/UBVxMzyOzGE
The problem is around 17sec mark.


Slasher

#12
Because it is quite quick could you not try

Code: ags

 cStarman.LockView(21);
 cStarman.Move(350, 300, eNoBlock, eAnywhere)
 cStarman.Animate(0, 3, eOnce, eBlock);
 cStarman.Move(350, 300, eNoBlock, eAnywhere)
 

isatche

Hi,
thanks, but it doesn't work. he tumbles in place, then slides back on his belly and freezes at first frame in the end. It made me giggle so it's a plus :)
I'm starting to thing that something's wrong with my version of AGS (3.4.3) or I made some stupid mistake somewhere else in a script to make it trigger like this or something.
It just happens when I do this with character. If I do it with an object, it works fine. So I will replace the character with the object and at one point when the cutscene is done, I will switch back between an object and a character.

Slasher

#14
Could be a scripting confliction somewhere..

Tumble should only loop once...

It's still in Lockview...

Cassiebsg

#15
Just a thought, but could you replace the animate+move with a walk command instead? Since walk moves and plays the animation.

Edit: and/or split the animation in 2. Use the tumbling as loop 0 and flat on the floor as loop 1, then run loop0 and end at loop 1.
There are those who believe that life here began out there...

Crimson Wizard

#16
You guys....

I just made a test game with this loop and only 3 above script lines, and this behavior reproduces (AGS 3.5.0).


If you slow animation down (set delay 5 etc), you can clearly see that animation begins playing, but as soon as character stops it is overriden and starts playing anew.

Can't remember for certain, but maybe we heard about this issue before? (I mean, this seem like something easily noticable...)   and so far it looks like a serious mistake in the engine.


UPDATE: same happens if you do non-blocking movement.

UPDATE2: If you make moving distance long enough for the first animation to complete, then upon stopping moving it does not play full anim again but resets loop to frame 0 and stays there.

Crimson Wizard

#17
@isatche

This workaround is best that I could come with after experiments. It replaces Move command with manual coordinate change. This should work because you use eAnywhere, so do not need pathfinding here:

Code: ags

       player.LockView(21);
       player.Animate(0, 3, eOnce, eNoBlock);
       while (player.x > 350)
       {
           player.x -= 5; // change 5 to the wanted speed
           Wait(1);
       }



PS. Not relevant to the problem at hand, but each View you create adds a script constant identical to the view's name in caps. E.g. if you create View called vTumble there will be script constant VTUMBLE equal to the View's ID.
Then you can use this constant instead of bare numbers, like:
Code: ags

player.LockView(VTUMBLE);

this may make it easier to understand your code in case you forget something.

Snarky

#18
An alternative solution in this case would be to just… let the animation play twice, because it looks pretty cool. :P :-D

Good job confirming it's an engine bug, CW! Yes, once the problem was narrowed down it did start to sound vaguely familiar, but I wasn't able to dig up a previous report of the bug. Edit: The same problem was previously reported here, but the cause was not found.

(When fixing this bug, maybe take a look at this one too, if it hasn't already been addressed.)

Crimson Wizard

#19
There's also something similar, but idk if related or not: https://github.com/adventuregamestudio/ags/issues/935
I will open a separate ticket just in case. https://github.com/adventuregamestudio/ags/issues/1123

SMF spam blocked by CleanTalk