Character position

Started by MarvinS, Wed 07/04/2004 22:22:15

Previous topic - Next topic

MarvinS

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 ?


Scorpiorus

#1
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;
}

MarvinS

But the Help of AGS says that this variable are read-only, and should not be modified.
So it's false ?

Alynn

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...


SMF spam blocked by CleanTalk