Character only walk if I click close to walkable area?

Started by daryl, Sat 07/04/2007 21:37:10

Previous topic - Next topic

daryl

Hi,

I've just begun creating my game and ran into a problem. It doesn't seem that I can click anywhere on the screen and have the character walk as close as he can on the path I created. Sometimes he just stops, or even choose to go in the other direction. I believe either the walkable areas are very restricted in how one can create them, not too curvy etc.. or I am missing something else. Here's a pic to show what I mean:



Greatful for any help, thanks!

Fee

Id say maybe try making the path wider and more straight.'Possible a problem with it calculating waypoints. Tho im a noob so i really dont know for sure.

I have a similar problem on some of my maps where the walkable ares are complicated. Alot of the time it just appears to crash whilst ploting a path through the maze. Kinda stupid if you ask me.

Not sure how many waypoints the game automatically makes, but its way too many. Especially when the maps are complicated maze type things.

Since people should have tio find there way through a maze, the waypoints it makes it you can click somewhere that seems unreachable game pauses for a few seconds and he makes his way all the way there. If its not possible to get there the game pauses for like 5 seconds apptempting to plot a path, then does nothing.

Other times he just starts walking there and whehn he gets stuck hes teleported to another part of the map..

I guess ill ask in here before i go starting a thread about it since its a similar problem...

Is there a way to turn this off? I got a dam fast PC so i feel for anyone whos running old hardware. If i havbe to wait 5 seconds i cant imagin how long someone on an old pentium has to wait.

Ashen

AS Fee suggested, try thickening the walkable areas a bit. the minimum recoomended thickness is about 3 pixels - most of the path looks OK but there are a few places that don't (e.g. partway down the right leg of the triangular part, left of the word 'PATH', about halfway up the P, under the second C of 'CLICK', and the L of 'CLOSER').
I know what you're thinking ... Don't think that.

daryl

Thanks Fee, Ashen for your replies!

I tried thickening the path but it doesn't seem to be the problem as nothing changed. Here's another pic on the thicker path that I painted and cursor and character positions. If I click where the cursor is the character doesn't move an inch. It only works if I click lower than that, closer to the path. To me the path isn't very complicated, but I can't find any info on the restrictions when creating paths, except the recommended 3 pixels thick. 





I even tried to fill everything below the path as well so it became a huge walkable area but the character still stops if I click too far up. Could it be something else? In classic Lucasarts games you could click anywhere on the screen and the character walks as close as he's permitted to, if I remember it correctly. I'm really hoping AGS is cabable of this as well.

Thanks again!

Fee

Why would you want to click up there to walk on the path?

Id say the reason he doesnt move is because you are clicking nowhere near a walkable area. You can click outside a walkable area, and the character will try get there if its close enough i think. The reason also in your first post is basically the same. He stops at that point because that is the closest point to a walkable area.

Like i said before im new at this so i could be mistaken. But that seems pretty logical to me. :P

daryl

Well I suppose the only reason would be that I would want the character to walk left, but the path of which he walks in the painted background is not as obvious as the path mask, and I wouldn't want to have the player bother or guess where to click for the character to walk left.

Or do I have to incorporate that into my painted backgrounds? Really obvious paths to walk?

Thanks

Khris

It's probably due to the way AGS's pathfinding works. To AGS, the point the player is standing at is already the closest one from the spot you clicked on.

You could work around this by doing something like this:
Code: ags
function on_mouse_click(MouseButton button) {
  ...
  if (button==eMouseLeft) {
    if (mouse.Mode==eModeWalk && player.Room==X) {    // replace X with room no.
      int i=mouse.y;
      int x=mouse.x;
      int y=i;
      while(i<player.y) {
        if (GetWalkableAreaAt(x, i)>0) {
          y=i;    // found walkable area
          i=player.y;   // exit loop
        }
        i++;
      }
      ProcessClick(x, y, mouse.Mode);
    }
    else 
      ProcessClick(mouse.x, mouse.y, mouse.Mode);
  }
  ...
}

daryl

thanks so much KhrisMUC for offering help and your time.

I pasted the code into the Room script, I had to remove the ... dots from the code or else AGS complained about a parse error. I looked at eModeWalk and changed to eModeWalkto as was the right command, and replaced X with my room number, 1. Is there something else need to be put in? The behaviour is still the same from the character.

Thanks.

Khris

No problem :)

This is supposed to go inside the (already existing) on_mouse_click function in the global script; that's why I've put the dots in there, they represent existing parts of the function.

An on_mouse_click inside a room script will never get called, that's why nothing has changed yet.

Ashen

Quote
An on_mouse_click inside a room script will never get called
It should, according to the manual (and in my experience). on_mouse_click and on_key_press functions can also exist in individual rooms scripts, and Module scripts. However, they're called before the Global version - since Khris' code is non-blocking, the Global on_mouse_click call is probably overriding the room-based one, so it looks to be behaving the same.

If you only need this in one room, the room-based version should work - just use ClaimEvent to stop the Global one from being called.
I know what you're thinking ... Don't think that.

Khris


daryl

I discovered why I have this problem, it was due to a big hotspot with a walkpoint, and while clicking on the hotspot he always moved to the walkpoint, and when he stopped and I continued clicking to the left, still on the hotspot, he stayed put. Sorry if I've waisted some of your time, but I really couldn't figure it out before.

Your help has been much appreciated none the less. Thanks a ton.

SMF spam blocked by CleanTalk