MODULE: rellax 0.4.0

Started by eri0o, Mon 07/10/2019 03:26:58

Previous topic - Next topic

Laura Hunt

#40
I see, thanks for replying!

Could I alter these values manually in the module code, or will I break something? From what I gather, I might need to change the 0.04 value in line 272, as well as the 40x40 box in lines 307 and 308:

Code: ags
  _cam_window_w = 40;
  _cam_window_h = 40;


Is this correct? Anything else I might want to tweak? :)

Quote from: eri0o on Sat 15/01/2022 09:51:05
Ah it can also be the still ticks. Can you make your game 60fps instead of 40fps? It should take half a second on a 60fps game, I can also expose the still ticks, these were made for when a character falls it falls downwards, it only matters if the movement is done without leaving the box borders.

The game is already set to 60 (it might look like it has a lower fps because the gif is captured at 33 fps).

Laura Hunt

#41
So I managed to find a workaround by commenting out these lines in order to set the still ticks to a fixed value of 30:

Code: ags
void doSmoothCameraTracking(){
  //if(_prev_c_x == _TargetCharacter.x && _prev_c_y == _TargetCharacter.y)
    //_count_still_ticks++;
  //else
    _count_still_ticks = 30;


By doing this, now the camera follows the character as soon as it moves, instead of waiting until it stands still, so yay I guess :-D (disclaimer: as mentioned above, the game runs at 60 fps but the gif was captured at 33 fps, so it doesn't look as smooth here as it does in-game).



I've tried with different values below 30 and also with 31 (as from what I can see, all values greater than 30 yield the same result) and 30 seems to be the smoothest. However, although the camera scroll in itself is smooth, the character's movement still looks a little bit jerky. Is there any other parameter I could tweak further in order to improve this?


eri0o

The only way I found to truly unjerk the movement is to not use movement linked with animation. In my games I only use it in rooms where the camera doesn't move, and every other rooms I don't. The usage of still ticks and the box alleviates it but only works if the character still moves reasonably fast.

Set your playable Character MovementLinkedToAnimation (anti-glide) to off and see how well it works. If the room has lots of scrolling the gliding is not very perceptible.

You can of course edit the code of the module, I want to update it so it's possible to change these values without doing so, because then it should be easier to everyone. :)

Laura Hunt

Quote from: eri0o on Sat 15/01/2022 13:04:20
Set your playable Character MovementLinkedToAnimation (anti-glide) to off and see how well it works. If the room has lots of scrolling the gliding is not very perceptible.

It does look better! The only issue is that unlinking movement and animation means I don't quite have the same fine degree of control over the character's movement speed, but for now it's a good solution :)

Tarnos12

Hello,

I have a question regarding this module.

Is there a way to snap camera to the player x/y position on room load?(before fade in)
It looks weird when the camera moves when entering new area.
I would like the camera to be at the center(including offset) when entering new room.

Can this be achieved?

Thanks

shaun9991

I've just seen this module, it looks great!!!

I've basically made an entire game, with lots of parallax, using ABK's Smooth Scrolling + Parallax module. Do you think it's possible to sort of "upgrade" to rellax from this or best to stick to the ABK module (I'm worried it might cause chaos with the existing code!)? It would be amazing to get truly smooth scrolling, which this new module seems to be able to do.

Many thanks,
Shaun
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

eri0o

#46
Updating to 0.2.0!

  • additional StandstillCameraDelayY, CameraLerpFactorX, CameraLerpFactorY, CameraWindowWidth and CameraWindowHeight attributes;
  • defaults have changed, hopefully they are more useful for Adventure Games;
  • Camera interpolation now uses a float camera position and this position is synced occasionally to the Camera, this should fix the issue reported by Flugeldufel here...;
  • demo is now built using AGS 3.5.1.17;

If someone would like to come up with a demo room that uses parallax and is a more traditional adventure game room, please hit me up, I did not have any ideas and also Adventure Game assets are hard to come by, so if you have an abandoned one, or have the art chops, send it my way.

I will at some point answer other things, I am still thinking about Laura's issue with traditional AGS walking characters that have MovementLinkedToAnimation, so far the only way I could come up is to have an additional character with anti glide off and move both at the same time, with the camera targeting the second... Unfortunately that is not very portable to put in a module...

Quote from: Tarnos12 on Mon 21/02/2022 21:03:27
Hello,

I have a question regarding this module.

Is there a way to snap camera to the player x/y position on room load?(before fade in)
It looks weird when the camera moves when entering new area.
I would like the camera to be at the center(including offset) when entering new room.

Can this be achieved?

Thanks

Updating to 0.2.1!

Not sure if I understood, made a new 0.2.1 release, added AdjustCameraOnRoomLoad property, default is true, it should quickly adjust the camera on room load, you can set it to false to keep the old behavior if you miss it! Please verify if this is enough.




I am currently investigating if there are better ways to provide smoothness as the current implementation may not be as smooth in some cases, like low resolution and slow characters... Finding lots of interesting stuff in other places too.

I am also investigating a camera specific to following a character walking a path, if I can estimate the time it takes for the character to reach the destination and I know the destination, I can do something similar to a camera tween to that instead of directly tracking the player, and in this way I can ignore the stepped interval the character normally moves on screen.

Tarnos12

Quote from: eri0o on Mon 02/05/2022 02:36:53
Not sure if I understood, made a new 0.2.1 release, added AdjustCameraOnRoomLoad property, default is true, it should quickly adjust the camera on room load, you can set it to false to keep the old behavior if you miss it! Please verify if this is enough.

Hey, I don't get any notifications on ags forums so I missed it, but I happened to update rellax today and used those extra variables, unfortunately that did not help.
The code is doing it's job, but there is another function that overrides that.
I have put an issue on github with a bit more specific information.

A way of "resetting" the camera would be great, I just don't want any movement when I change the room, the camera should be at the end position.

eri0o

#48
Hey! Thanks for the well written GitHub issue! I was able to understand and track down the issue! I made a new 0.2.2 release, I think it's working now, please verify!

I am also working on a new implementation which will make the camera work slightly different when it's tracking a character that is following a path vs a character that is walking by some other way, the idea is the character following a path we can guess how long it will take for the character to get there, and loosely track the camera towards it, instead of following the character steps. The problem with this approach is that while the whole world looks non-jerky, the character itself is looking a bit weird so far, balance both is being a bit hard...

I also did not forgot shaun, I am thinking about if I should figure a compatibility mode for people coming from Ali's module, haven't figured that yet though...

Tarnos12

Quote from: eri0o on Tue 03/05/2022 00:44:58
Hey! Thanks for the well written GitHub issue! I was able to understand and track down the issue! I made a new 0.2.2 release, I think it's working now, please verify!

I am also working on a new implementation which will make the camera work slightly different when it's tracking a character that is following a path vs a character that is walking by some other way, the idea is the character following a path we can guess how long it will take for the character to get there, and loosely track the camera towards it, instead of following the character steps. The problem with this approach is that while the whole world looks non-jerky, the character itself is looking a bit weird so far, balance both is being a bit hard...

I also did not forgot shaun, I am thinking about if I should figure a compatibility mode for people coming from Ali's module, haven't figured that yet though...

Thanks for the update, tested and it works great!

eri0o

#50
Since 0.2.1 of rellax, I switched the camera position to use a float, and clamp to int positions when using it. I recently had an idea to move the viewport too along with the camera, with the residue of these positions!

Code: ags
    Game.Camera.SetAt(FloatToInt(_next_cam_x), FloatToInt(_next_cam_y));
    Game.Camera.SetSize(320, 180); 
  
    int residue_x = FloatToInt(_next_cam_x * 4.0, eRoundNearest) - FloatToInt(_next_cam_x) * 4;
    int residue_y = FloatToInt(_next_cam_y * 4.0, eRoundNearest) - FloatToInt(_next_cam_y) * 4;
    
    Screen.Viewport.SetPosition(-residue_x, -residue_y, Screen.Width, Screen.Height);


Above is an example of a game screen that is 1280x720, when the game camera is for a 320x180 game. This gives us an extra 0.25 times 4 positions we can move around

The effect looks like this: video_1.mp4, video_2.mp4.

It needs some adjustments, but with this, the camera smoothness can be made much better for lower resolution games. This is not yet implemented in rellax, but I am looking into and just thought I would share it here - the experimental commit is here.

Of course, going this route you need to have all your GUIs scaled up to compensate, which is not trivial as we are now in AGS... But, this is interesting still.

TheVolumeRemote

Question! First, thank you @eri0o so much, Rellax has been invaluable to my dev and game:) Okay so Ive got a room that is taller than the rest of my rooms. One of my playable characters can float way up high, the other can only walk on the ground. When I switch from the floating way-up-high player, to the player on the ground, Rellax doesn't go all the way to the ground. It goes most of the way but cuts off at the walking players knees and anything below that isn't in sight.

What can I do to get Rellax to go to/return to the ground?

Code: ags
Rellax.CameraOffsetY = 50;

which I would think is what I need to do, doesn't seem to do anything, whereas
Code: ags
Rellax.CameraOffsetY = -50;
does what's expected however that is in the wrong direction, this offsets the camera even higher up.

I've tried a lot of bad ideas like
Code: ags
Rellax.CameraOffsetY = cEgo1.y;
but no luck. I have some plan B's I can employ but i'd rather understand what I doing wrong or how I could handle this correctly.

I hope this is coherent, thank you for your awesome module and for any help :)

AndreasBlack

@TheVolumeRemote
Did you forget to switch rellax to the current playable character? I know i did that mistake. It doesn't do that automatically! Rellax.TargetCharacter  ???

Question for @eri0o everytime i re-enter a room from a different spot the rellax jumps fast back to it's original position. How do i leave it from where it was when i left the room? I tried manually moving the object and such, but it doesn't do the trick, or disabling rellax and walking onto a region = enabling it still not really what i'm looking for, Thanks!

eri0o

@TheVolumeRemote Can you try this version here and see if it improves something for you?

rellax.zip

What I imagine can be a problem is if the difference in y distance is small, it may not give enough kick in the lerp, the version above should by default try to kickup in smaller distances - it also has an optional parameter so you can manually set the CameraLerpFactorX and CameraLerpFactorY, but lets try first the defaults and see what happens.

@AndreasBlack it sounds like the previous issue (forum comment, github link) from Tarnos that was fixed with the new AdjustCameraOnRoomLoad property, that defaults to true. Are you using the 0.2.2 version? Does using the above version changes anything for you?

TheVolumeRemote

@AndreasBlack thanks mate, but my problem happens upon switching to my other playable character, where it does target the newly selected character, it just doesn't bring the camera all the way back, or down enough :)

For your issue, perhaps call targetCharacter on room_load and/or on room_load try this
Code: ags
Rellax.AdjustCameraOnRoomLoad = true;

TheVolumeRemote

@eri0o what timing! Ok I will try this now and report back, thank you!!

TheVolumeRemote

@eri0o Unfortunately this didn't work but you are right about the small margins, I'd guess the returning camera is only off by about 50-60 pixels to where it should be returning to.

Let me know if a video would help, and any advice on what to perhaps set Lerp (or anything else) to, would be greatly appreciated :)

eri0o

@TheVolumeRemote Hey, sorry for taking a little while, the ideas I had didn't change much beyond that build I sent, can you give the x,y position of each character, the game resolution and the room size? Just so I can properly reproduce the issue.

The workaround idea I have is to temporarily disable the smoothcam, pan using Tween on the Camera, and then later turning it back on.

TheVolumeRemote

#58
Hi @eri0o thank you, I am super grateful you've been giving it thought!
The game resolution is 320x200 the room size is 520 x 326 (first room in 83 rooms/the game that is not 200px in height). The character bound to the floor starts the room at 87X 318Y and his Y never changes (room to room, the game is Left to Right movement only). The floating character has a walkable that is essentially the entire room, beginning at 47X 316Y. The issue arises if I move the floating character up to say 47x 90Y and then target the character standing on the ground.

Here is a quick screengrab to help you help me, I worry I confuse things by explaining it so hopefully the video makes it clear. https://www.dropbox.com/s/h8wls0v4wx8e5fq/TPF_Rellax.mov?dl=0

thank you so so much for your help, the only 2 rooms I have that are taller than 200px are the second to last and last rooms in the game and the height is part of an exploration puzzle so I really appreciate your help with this, I've been a lot calmer and pleasant to be around since you took the case lol

TheVolumeRemote

@eri0o and for what it's worth, I can kind of click the camera down to where it should be which while a little strange, I thought might be helpful for you to know in thinking of a solution :)

here's what that looks like https://www.dropbox.com/s/hwtx6u42cbp4hql/TPF_Rellx_Clicks.mov?dl=0

SMF spam blocked by CleanTalk