Hi there,
For the life of me I can't find out what is wrong with the following code:
int i = GetPlayerCharacter ();
SetCharacterView (i, EGOFALL);
AnimateCharacterEx (i, 0, 5, 0, 0, 1);
//SetCharacterViewEx (i, EGOFALL, 5, ALIGN_CENTRE);
AnimateCharacter (i, 5, 5, 1);
MoveCharacterBlocking (i, 100 + Random (60), 175, 1);
AnimateCharacterEx (i, 4, 5, 0, 0, 1);
ReleaseCharacterView (i);
Okay, so what does it do... it is triggered when EGO moves onto a certain area, i.e. a cliff edge. Hence animation EGOFALL is used, which has a number of loops for falling and hitting the ground.
The first AnimateCharEx causes his arms to wave wildly (loop 0). The second one at the bottom is a splat where he hits the ground (loop 4). This part works.
The part that doesn't is the central part. EGO moves down (MoveCharBlock) using his falling animation, either selected by the AnimateChar directly above it, or the SetCharViewEx. But it doesn't work; EGO gets the wrong view every time! Can anyone figure out why?
Thanks!!
I didn't read much, but are you sure that the falling animation is using the "down" direction loop of the character?
Moreover, I don't quite understand why you set his target X coordinate to "100+Random(60)", if he's falling down, shouldn't his X coordinate be the same as that before he falls? Unless that "random" parameter was actually intended for his Y coordinate, so you may have got the X,Y coordinates swapped.
What I was thinking is:
MoveCharacterBlocking (i, character.x,100 + Random (60), 1);
MoveCharacter*() functions use character's normal view whereas the SetCharacterView() sets a temporary view which AGS resets when moving a character. ChangeCharacterView should do the trick:
...
ChangeCharacterView(i, EGOFALL);
MoveCharacterBlockingÃ, (i, 100 + Random (60), 175, 1);
...
Gilbot -> he slides sidewards while falling (icy slope, you know). The coordinates are not the problem.
I am indeed not using the 'down' loop of the view for falling. However, the character isn't showing what is actually in that down loop, either!
And sorry but the MoveChar does not use the character's normal view either (which would be a walking animation); instead I get the slamming into the ground animation while falling...
MoveCharacter will treat it like a walking animation, so you need to make sure that the relevant loop number has the falling animation in it (if he's going right, that would mean loop 2).
Since he's falling, I'll try for down :)
So if I understand correctly, if I want a character to move in any direction using the view loop for another direction, the easiest way is to do an AnimateChar and manually increment character[].x and .y ?
The easiest way is to create another view ;) :P
Yes, this is a bit of a limitation of using characters. I suppose there should really be two seperate commands, WalkCharacter and MoveCharacter, one of which uses the default walking animations, and the other of which doesn't interfere with animation.
Planning on 2.7 any time soon? :)
(just curious actually, I have plenty of things to do in 2.6 already)