tzachshabtay / MonoAGS

AGS (Adventure Game Studio) reimagined in Mono
https://tzachshabtay.github.io/MonoAGS/
Artistic License 2.0
27 stars 8 forks source link

AGSCamera does not properly target object that has parent and/or on parallax layer #270

Closed ghost closed 6 years ago

ghost commented 6 years ago

If an object has a parent (it's X,Y properties define relative coordinates and not absolute room ones), and/or that object is bound to RenderLayer with ParallaxSpeed different from (1,1), then AGSCamera fails to correctly center viewport on that object.

UPD Similarily, AGSCamera does not take these possible cases into account when checking out for zoom areas (see getTargetZoom method). Because of this target object that has parent may not trigger camera zooming when on zooming area, because camera passes its relative coordinates, while Area expects absolute ones (?).

NOTE: I do not know if parallax problem may be considered only specific to the camera. I opened another issue regarding the object's relative coordinates not taken into account in more general case: #271. If parallax effect should also be applied in these cases, then current issue should probably be closed as a duplicate and more narrow case.

tzachshabtay commented 6 years ago

So, this PR (https://github.com/tzachshabtay/MonoAGS/pull/276) should fix the parent issue, but as for the parallax.. I'm not sure how it would work, actually. The parallax location is changed based on the viewport location, and the camera sets the viewport location. So if the camera took the parallax location into account: wouldn't this result in an endless loop (viewpoint change -> parallax change -> viewport change -> parallax change)?

ghost commented 6 years ago

The parallax location is changed based on the viewport location, and the camera sets the viewport location. So if the camera took the parallax location into account: wouldn't this result in an endless loop (viewpoint change -> parallax change -> viewport change -> parallax change)?

I think for any point on parallax layer there must be a viewport coordinate that would make that point appear in the necessary point on screen.

BTW, did not pay attention to this, with introduction of the viewport Pivot, does camera react on Pivot change?

tzachshabtay commented 6 years ago

I think for any point on parallax layer there must be a viewport coordinate that would make that point appear in the necessary point on screen.

I'll try playing around and see if I can come up with something, though I'm a little skeptic.

BTW, did not pay attention to this, with introduction of the viewport Pivot, does camera react on Pivot change?

No, the current built in camera assumes the pivot is the bottom left.

tzachshabtay commented 6 years ago

I've added parallax consideration for the camera in this branch: https://github.com/tzachshabtay/MonoAGS/tree/CameraParallax

This seem to work fine in the demo game if I give the character parallax speed. Can you check if it works for your scenario?

And also congratulations on the awards!! :)