I am trying to make a character flee from the player character as the player character approaches. I am trying to do this in the room_RepExec() method but I am having problems.
function room_RepExec()
{
if ((cCharacter.x - 300) < (cChar2.x))
{
cChar2.Walk(cChar2.x - 300, cChar2.y, eNoBlock, eAnywhere);
}
}
When cCharacter approaches cChar2, cChar2 will begin to walk in place but will not actually move anywhere. If cCharacter goes back over the -300 line, cChar2 will then move forward.
I would like to make cChar2 move forward the first time but I am not sure why this is not happening.
Any ideas?
When the player is close, you are repeatedly telling cChar2 to Walk, so he never gets going.
You should check if cChar2.Moving is clear first.
if (cChar2.Moving == false && cCharacter.x - 300 < cChar2.x)
{
cChar2.Walk...
}
Thanks friend that seems to have done it.
Another couple of problems now. When cChar2 is walking away it gets a bit choppy and doubles up occasionally. Any known way of avoiding something like this?
Additionally, if cCharacter is in the same y-position that cChar2 is in then it will halt when it gets to cChar2's original postion before it moved. Do you know why this would be?
Thanks again!