Character does not reach its destination (SOLVED)

Started by pcj, Fri 23/02/2007 15:04:59

Previous topic - Next topic

pcj

I'm trying to position a character next to an object correctly, and walk him in from outside the screen with:

Code: ags
cSp1.Walk(110, 145, eNoBlock, eAnywhere);


Which gives me something like this.

So I modify the code, gradually subtracting from the X-coordinate one point at a time, with nothing changing, until I make it

Code: ags
cSp1.Walk(105, 145, eNoBlock, eAnywhere);


Making him jump to this.

Am I missing something?

edit by scorpiorus to specialize topic name since the problem has been tracked down
Space Quest: Vohaul Strikes Back is now available to download!

Gilbert

Check if the "Solid" option  is checked for that character, that may make him avoid "overlapping" with objects and other characters.

pcj

I unchecked it, it doesn't help.
Space Quest: Vohaul Strikes Back is now available to download!

Joe

I think what you must check, then, is the Object.Solid

I don't know if the are solid by default.

So try coding "object.Solid=false;"
Copinstar © Oficial Site

pcj

Setting the object's solidness to false also does not work.
Space Quest: Vohaul Strikes Back is now available to download!

Scorpiorus

Hmm, I'm not quite sure what you are after.

Do you say the Character.Walk() command makes him jump (i.e. teleport) instead of walking?

Also, you say you manually change the X co-ordinate, but is the character stationary while you're doing so, because you should not change his co-ordinates while he's moving (ie. cSp1.Walk is in action).

Could you elaborate a bit?

pcj

No, he always walks, but with

Code: ags
cSp1.Walk(110, 145, eNoBlock, eAnywhere);


he walks to the first spot, and for each increment of x-coordinate from there to just before

Code: ags
cSp1.Walk(105, 145, eNoBlock, eAnywhere);


he walks to the same spot, just to the right of where I need.  Then I change it to 105 and where he stops at the end of the walk is to the left, as in the second example.

I'm not changing the code in runtime.
Space Quest: Vohaul Strikes Back is now available to download!

Scorpiorus

#7
Ah I see, interesting... With eAnywhere he should definitely walk to the specified co-ordinates.

As others suggested, it may probably be because of other characters/objects blocking his way. But make sure you've unchecked the Solid option for the character on the way (not the walking character).

Also...

Press the tilde (`) key (usually to the left of the 1 key) to bring up the debug console and see what coordinates he moves to.

Try putting a Display check to find out what actual coordinates he comes at:

on_key_press:
Code: ags
if (keycode == 'D') // display coordinates on pressing the 'D' key
{
Ã,  Ã,  Display( "X: %d, Y: %d", cSp1.x, cSp1.y );
}


These coordinates should match those you pass into Character.Walk(), provided eAnywhere is here and nothing is blocking the way.

EDIT: Ah, instead of adding a Display you can simply press Ctrl-D to find out the info on the characters (such as their X,Y coordinates) in this room.

pcj

SP1 goes to 135,164 when he's supposed to go to 110,145, and goes to 105,145 when it's set to go there.
Space Quest: Vohaul Strikes Back is now available to download!

Scorpiorus

#9
Strange, I've just done a couple of tests but was unable to replicate it, it all worked ok for me.

Are you definitely sure you are not changing character's x/y coordinates while he is moving?

Any chance you could upload the roomX.crm file for us to take a look at?

EDIT:

Furthermore...

You said you make him coming from the outside of the screen; what if you put him so he's on the screen and try moving from there?

And does eBlock make any difference?

pcj

#10
Well, see if it helps:

http://www.vohaulstrikesback.com/temp/Room101.crm

EDIT:

No, I'm not changing them while he is moving.

Quote from: Scorpiorus on Fri 23/02/2007 20:48:16
You said you make him coming from the outside of the screen; what if you put him so he's on the screen and try moving from there?

And does eBlock make any difference?

It needs to be eNoBlock so the two Sequel Policemen walk in at the same time (or a bit staggered actually, I put in a Wait command in so they don't cross since they start at the same spot).  The other SP is eBlock.

It does work when the Sequel Policeman is already on the screen, but then that doesn't generate the entrance effect I want.  Maybe it has something to do with the walk speed?
Space Quest: Vohaul Strikes Back is now available to download!

Scorpiorus

#11
I get The page cannot be found if try download the file.

QuoteIt needs to be eNoBlock so the two Sequel Policemen walk in at the same time (or a bit staggered actually, I put in a Wait command in so they don't cross since they start at the same spot).Ã,  The other SP is eBlock.

Interesting... So you are blocking the script with the other character to make them walk simultaneously. My wild guess would be the first policeman is just somehow interrupted on his way.

Can you post the whole script code responsible for their movement, including the other guy?

QuoteIt does work when the Sequel Policeman is already on the screen, but then that doesn't generate the entrance effect I want.  Maybe it has something to do with the walk speed?

Hmm, and what are their speeds?

pcj

#12
Sorry about the 404...webserver didn't recognize the filetype.  It should work now.

Code: ags
// room script file

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for Room: First time player enters room
oConsole.Solid = false;
/* code removed for brevity */
Wait(160);
cSp1.Walk(130, 160, eNoBlock, eAnywhere);
Wait(40);
cSp2.Walk(160, 180, eBlock, eAnywhere);
cSp1.FaceLocation(130, 200,eNoBlock);
cSp2.FaceLocation(110, 180, eNoBlock);
/* code removed */
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE


(EDIT: Oh, in the above code I was tinkering with it when the SP was already on the screen, 130,160 seems to be the right position)

Quote from: Scorpiorus on Fri 23/02/2007 21:32:01
Hmm, and what are their speeds?

I left them at what the default was, 3, and uniform movement speed is enabled.
Space Quest: Vohaul Strikes Back is now available to download!

Scorpiorus

Ah, you see the script code is probably being unblocked too early, you need to wait for the first character:

Code: ags
function room_a() {
Ã,  // script for Room: First time player enters room

Ã,  Ã,  Wait(160);
Ã,  Ã,  cSp1.Walk(130, 160, eNoBlock, eAnywhere);
Ã,  Ã,  Wait(40);
Ã,  Ã,  cSp2.Walk(160, 180, eBlock, eAnywhere);

Ã,  Ã,  while (cSp1.Moving) Wait(1); // wait for the first cop to reach his destination

Ã,  Ã,  cSp1.FaceLocation(130, 200,eNoBlock);
Ã,  Ã,  cSp2.FaceLocation(110, 180, eNoBlock);

}


...or a more generic version:

Code: ags
function room_a() {
Ã,  // script for Room: First time player enters room

Ã,  Ã,  Wait(160);
Ã,  Ã,  cSp1.Walk(130, 160, eNoBlock, eAnywhere);
Ã,  Ã,  Wait(40);
Ã,  Ã,  cSp2.Walk(160, 180, eNoBlock, eAnywhere); // *eNoBlock too*

Ã,  Ã,  while (cSp1.Moving || cSp2.Moving) Wait(1); // wait for both

Ã,  Ã,  cSp1.FaceLocation(130, 200,eNoBlock);
Ã,  Ã,  cSp2.FaceLocation(110, 180, eNoBlock);

}


pcj

Heh, if that isn't the most counter-intuitive glitch...

Thanks Scorpiorus, that works.
Space Quest: Vohaul Strikes Back is now available to download!

Scorpiorus

No problem, I'm glad you got it working :)

SMF spam blocked by CleanTalk