Jerkiness when using Character.FollowCharacter on a scrolling room

Started by Héctor Bometón, Wed 29/07/2020 21:30:19

Previous topic - Next topic

Héctor Bometón


Why does that happen? I'm controlling the viewport manually on this room, but it also happens in any other room with the default scrolling.

Is there anything I can do? (See video)


Khris

You can try giving the cat a different AnimationSpeed, or replace default scrolling in all scrolling rooms.

eri0o

What do you mean controlling viewport manually? You mean Camera right? For ONLY setting the camera it's usually a good idea to use late_repeatedly_execute_always because then other movements are already updated. Also how are you moving the cat?

Danvzare

In the character tab, under the movement heading in the properties window is an option called "MovementLinkedToAnimation", set that to false.
You'll have to mess about with the movement speed and animation delay a bit, but it should sort out all of your jerkiness problems. That's what I do on all of my games.

Héctor Bometón

QuoteWhat do you mean controlling viewport manually? You mean Camera right? For ONLY setting the camera it's usually a good idea to use late_repeatedly_execute_always because then other movements are already updated. Also how are you moving the cat?

Well... I was using SetViewport because I was already comforable with that solution before the Cameras update came in and never bothered to switch. Now I just wiped out all mention to Viewport in that room script, and changed it for this:

Code: ags

function late_repeatedly_execute_always()
{
  Game.Camera.SetAt(player.x - 240, player.y - 175);
}


The result is the same. Just like the first video I shared.

How am I moving the cat?

Code: ags
cGato.FollowCharacter(player, 10, 10);


It also has a little code in repeatedly_execute_always to make him stand up when he stops walking, which I was pretty sure wasn't the problem, but I also tried without that code in case it was messing up the whole thing. It wasn't.

This problem reminds me of the jerkiness I got when first trying to achieve parallax for background and foreground objects. I solved it by setting the Viewport manually, so that way the viewport and the new position for the objects refreshed at the same time, and it worked, but not for this. I'm probably missing something...

QuoteIn the character tab, under the movement heading in the properties window is an option called "MovementLinkedToAnimation", set that to false.
That just made things wierder, and tweaking the speed doesn't make it better.


eri0o

What's the cat character speed and delay ? Also how many frames does how walk animation has?

Héctor Bometón


The cat's MovementSpeed is 5, and Animation Delay is 3.

I tried pairing those numbers, and also pairing the whole cat Movement parameters to the player's. Nothing.

Héctor Bometón


I just used a duplicate of the player character (I use it for mirror effect) to try it and got the same result.

I also tried making the camera follow the character following the player, and then the player is the one who gets the jerkiness. I don't know if that sheds any light on the issue...

Code: ags
function late_repeatedly_execute_always()
{
  Game.Camera.SetAt(cMirror.x - 240, cMirror.y - 175);
}



Héctor Bometón


It also happens when I try it in a room without any Viewport or Camera code at all. Just the default horizontal scrolling:


eri0o

Movement Speed, when using character movement linked to animation means number of pixels the character move in a single step (and maximum number of pixels the character can move in it's last step). The delay, is the frames for a step which is also the delay of the animation, because the movement is linked to animation.

https://adventuregamestudio.github.io/ags-manual/Character.html#charactersetwalkspeed
https://adventuregamestudio.github.io/ags-manual/Character.html#characteranimationspeed
https://adventuregamestudio.github.io/ags-manual/Character.html#charactermovementlinkedtoanimation

So if the camera follows the EXACT movement of a character, it will move only when that character moves.

My suggestion is to not move the camera exactly along with the a character and either smooth it out with a equation or have regions in the room and reaching each region forces the camera to center to that region (sort of like old-school NES Zelda).

(I also have a module for this, but since it requires adding two custom properties may be smart to backup your game before trying https://www.adventuregamestudio.co.uk/forums/index.php?topic=57489.0 )

Laura Hunt

Quote from: Héctor Bometón on Thu 30/07/2020 18:11:04

It also happens when I try it in a room without any Viewport or Camera code at all. Just the default horizontal scrolling:



Haha sorry for the off-topic but

Spoiler
I know exactly where that bar is. I went there last time I was in Madrid! https://twitter.com/deadidlegames/status/1210344795165675520
[close]

Héctor Bometón


Mmmm... Any easy way to check if the room is scrolling? I may have a workaround if I get to check that.

eri0o

I don't know exactly how to do it. Sorry  :(

Crimson Wizard

Quote from: Héctor Bometón on Thu 30/07/2020 19:13:53
Mmmm... Any easy way to check if the room is scrolling?

If you are using custom scrolling that's very easy because you are the one scrolling it :).

If you are using built-in scrolling, there's no "scrolling state", as scrolling is a momentary action that takes place when character is too far from he center of the screen.
One thought I have is that you may save old camera coordinates and compare them to new ones in rep-exec function. If they changed this means that scrolling occured. If you test this in late_repeatedly_execute_always - that will detect scrolling on current game frame. If you do this in repeatedly_execute or repeatedly_execute_always - that will detect scrolling on previous game frame.

eri0o

If they changed and the room width is bigger than camera width (for horizontal) and they are both (new and old camera coordinates) not smaller than half camera width or not bigger than room width minus half camera width.

Crimson Wizard

Quote from: eri0o on Thu 30/07/2020 21:22:34
If they changed and the room width is bigger than camera width (for horizontal) and they are both (new and old camera coordinates) not smaller than half camera width or not bigger than room width minus half camera width.

Why?

You sure you are not confusing camera and character coordinates?

Also, there's no need to test whether room is bigger, because if it's equal or smaller than the camera won't move at all.

SMF spam blocked by CleanTalk