Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: MarvinS on Wed 07/04/2004 22:22:15

Title: Character position
Post by: MarvinS on Wed 07/04/2004 22:22:15
Is there a way to move directly a character from one point to another without walking.

for example :
EGO position is (10,10)

-> SetCharacterPosition(EGO, 100,100);

And then EGO disappears and  appears at (100,100) position in the same time.

Is this possible ?

Title: Re:Character position
Post by: Scorpiorus on Wed 07/04/2004 22:50:40
Yep, there is no function but you can modify character[].x/y variables directly (just make sure character isn't walking):

character[CHARID].x = 100;
character[CHARID].y = 100;


Or building an extra function you like:

function SetCharacterPosition(int CharID, int newX, int newY) {
 if (character[CharID].walking) StopMoving(CharID);
 character[CharID].x = newX;
 character[CharID].y = newY;
}
Title: Re:Character position
Post by: MarvinS on Wed 07/04/2004 23:10:23
But the Help of AGS says that this variable are read-only, and should not be modified.
So it's false ?
Title: Re:Character position
Post by: Alynn on Wed 07/04/2004 23:29:02
If you read it carefully it actually says you shouldn't modify them unless the character is not moving... which is why in that handy function that Scorpiorus posted does this first

if (character[CharID].walking) StopMoving(CharID);

The reason being, you can get nasty results when trying to move a character and you set those variables at the same time...
Title: Re:Character position
Post by: MarvinS on Thu 08/04/2004 07:37:28
Ok, thanks. :)