Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: jumpjack on Thu 12/01/2023 09:59:37

Title: keep y position constantly increased while standing on a region
Post by: jumpjack on Thu 12/01/2023 09:59:37
I need that my character Y position is constantly added a fixed quantity as long as character remains inside a region.

I tried with this:

function region1_Standing() {
  //if (!raised) {
    cEgo.y -= 10;
    raised = true;
  //} else {
    // already raised
  //}
}

If  lines are commented, character flickers between "normal" and raised position.
If they are not commented, character Y position is changed only at the beginning, then turns back to the one calculated by pathfinder.
Title: Re: keep y position constantly increased while standing on a region
Post by: Khris on Thu 12/01/2023 10:22:20
This is a perfect use case for the .z property; use that instead. Unless that needs to happen in a blocking context, use the region's "walks onto" event to set .z to 10, and the "walks off" event to reset .z back to 0.
Title: Re: keep y position constantly increased while standing on a region
Post by: jumpjack on Thu 12/01/2023 11:51:39
Thanks!  :)