Changing Character's z Value

Started by xerca, Sat 17/03/2012 22:13:00

Previous topic - Next topic

xerca

I have a simple question. I need to move a character from one place to somewhere but at the same time I must change the z position gradually. Because it is going to a lower place. So how can I change its z property without blocking the script, but not in an instant?

I don't want to use y instead and move it normally, because it becomes a big problem both with being wrongly in behind or on front and scaling.

monkey0506

Looks like a job for repeatedly_execute and/or repeatedly_execute_always.

If the movement itself is non-blocking then you can do something like this:

Code: ags
function repeatedly_execute()
{
  if ((player.Moving) && (otherConditionsMaybe))
  {
    player.z--; // or change appropriately
  }
}


Keep in mind that repeatedly_execute can exist in any script except room scripts where it must be linked in the room's Events pane, and the default name is "room_RepExec" (you can change that, but the default is different).

The repeatedly_execute_always function works exactly the same way, except it is called during blocking interactions.

xerca

Quote from: monkey_05_06 on Sun 18/03/2012 01:30:44
Looks like a job for repeatedly_execute and/or repeatedly_execute_always.

If the movement itself is non-blocking then you can do something like this:

Code: ags
function repeatedly_execute()
{
  if ((player.Moving) && (otherConditionsMaybe))
  {
    player.z--; // or change appropriately
  }
}


Keep in mind that repeatedly_execute can exist in any script except room scripts where it must be linked in the room's Events pane, and the default name is "room_RepExec" (you can change that, but the default is different).

The repeatedly_execute_always function works exactly the same way, except it is called during blocking interactions.

Thank you! It works. I put it in the repeatedly_execute_always because its moving was blocking. I also had to do some extra stuff because the z level it is going changes everytime and I couldn't use the "moving" property because of its different moving style. But now it works just as I want.

SMF spam blocked by CleanTalk