Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Pax Animo on Sat 25/06/2022 12:18:06

Title: Set all character baselines. Solved
Post by: Pax Animo on Sat 25/06/2022 12:18:06
Hello,

So i'd like to simply change all the baselines of characters in game via character array size, i've tried this:

Code (ags) Select
function game_start()
{
  int test = Game.CharacterCount-1;  //gets the number of characters in game. (Without the -1 on the end i get an out of bounds error.)
  character[test].Baseline = 723; //my attempt to change all character baselines via the "test" variable.
}


Game loads without issues but the baselines don't change.

Edit: um ok, i see now what that code is doing, its getting the last character in the array and setting that character's only baseline.

Cheers in advance for any advice.

Title: Re: Set all character baselines.
Post by: Pax Animo on Sat 25/06/2022 12:30:33
Code (ags) Select
for (int i = 0; i < Game.CharacterCount; i++)
{
  character[i].Baseline = 723;
}


Oh this seems to work but not for all characters.

Title: Re: Set all character baselines.
Post by: Crimson Wizard on Tue 28/06/2022 15:04:07
Quote from: Pax Animo on Sat 25/06/2022 12:30:33
Oh this seems to work but not for all characters.

The code looks correct though. What happens instead? Are you absolutely sure you dont change Baselines somewhere else in script?
Title: Re: Set all character baselines. Solved
Post by: Pax Animo on Tue 28/06/2022 17:26:02
Thanks, all sorted now, I was setting the baseline of a character which fills the hole screen before running the for loop, it obviously needs to be after the for loop.

Edit: i see my mistake was not posted in the original code or this would have been solved much sooner, my bad. :-|