Hi, in this first function my character is walking to the specified coordinates, according to its position before he start to walk:
int loop;
function cajon_Interact()
{
if (cPedro.x > 470)
{
cPedro.Walk(550, 620, eBlock, eWalkableAreas);
loop = 1;
}
else
{
cPedro.Walk(400, 620, eBlock, eWalkableAreas);
loop = 0;
}
cPedro.LockView(ViewUsar);
//other things
}
I tried something similar with the following function, but this time, the character is always walking to the same destination, no matter the X coordinate he is at the beginning.
What am I doing wrong?
int loop4;
int Xcoor;
int Ycoor;
function hRio_UseInv()
{
if(cPedro.x < 430)
{
Xcoor = 350;
Ycoor = 720;
loop4 = 0;
}
else if (cPedro.x > 890)
{
Xcoor = 970;
Ycoor = 720;
loop4 = 1;
}
else
{
Xcoor = 640;
Ycoor = 720;
loop4 = 0;
}
if(cPedro.ActiveInventory == iBotella_vacia)
{
cPedro.Walk(Xcoor, Ycoor, eBlock, eWalkableAreas);
cPedro.LockView(20);
cPedro.Animate(loop4, 2, eOnce, eBlock, eForwards);
cPedro.UnlockView();
cPedro.LoseInventory(iBotella_vacia);
cPedro.AddInventory(iBotellaAgua);
}
}
Thanks!
I can't see anything wrong per se in it, maybe someone else with more experience can though.
- I would ask though which coords is cPedro always walking too?
And second, maybe take note of which coords he's at when it starts.
For that you could just add a display at the start of the function that shows exactly where's at: Display(String.Format("Pedro is at X: %d and Y: %d" , cPedro.x , cPedro.y)); (note that this code might have some flaws, since I'm typing it out of memory, but hopefully it's good enough for you to get it working).
Thanks Cassiebsg,
That was very helpful.
I just assigned values to the "WalkToPoint" property of the hotspot when I created it (I never use that, don't know what happened, maybe I was just testing how it works).
Ans yes, walking to this point was the first thing he does when interacting with that hotspot.
Thanks again, have a lovely day!
Ah, I did that on my first game as well and as a result I ended getting a huge headache to debug it. (laugh)