I have an idea to improve the Direct Control Script, but I need some help...
The problem with the current script most of all is that the waypoints are considered when the actor is walking using the direct control.
But I want the actor to ignore the waypoints when using the direct control.
Instead of having the actor "walking" by using the GoTo function you can have the actor walk ignoring the waypoints by using the PlayAnim function instead.
Problems of course are that because of the looping the actor won't stop moving and at the same time also ignores the unwalkable areas.
So in some way while he is "walking" you have to make sure that he stops short before reaching a unwalkable area and also find a way to interrupt the movement anyhow.
I've tried this out and it works more or less:
if(Keyboard.KeyCode==VK_F1)
{
while(Scene.IsWalkableAt(actor.X,actor.Y-15)==true)
{
if (actor.Ready==true) actor.PlayAnimAsync("actors/knight/up/move_up.sprite");
Sleep(20);
}
actor.Reset();
}
if(Keyboard.KeyCode==VK_F2)
{
while(Scene.IsWalkableAt(actor.X,actor.Y+15)==true)
{
if (actor.Ready==true) actor.PlayAnimAsync("actors/knight/down/move_down.sprite");
Sleep(20);
}
actor.Reset();
}
The problem here is if I want to walk down while he is walking up he will first finish walking up before walking down.
Also I don't believe the loop will end if I interrupt with any other key. First when the actor reaches a not walkable area. (right??)
Does anyone have any idea how to solve this?