Solid problems

Started by geork, Mon 28/05/2012 20:33:52

Previous topic - Next topic

geork

Hey all! I searched this through the forums, but no-one seems to have this specific problem.

I'm fooling around with some RTS-ish style mechanics (purely for programming practice) and I noticed that solid characters seem to walk on top of each other. Every character is declared solid and has a blocking height and width of 50. However, when I ask them all to move to the same spot, they all hurry towards it and all move into that exact spot. Sometimes some will pause and then continue 1 by 1 as the first reaches it's destination. The nex time I ask them all to move somewhere else, they politely wait for one to go at a time, but nevertheless end up in the exact same spot as the others.

I dunno if it's possible for characters to merely get blocked by others, and stop there, or if they will invariably end up in the same place. It doesn't seem like a character.Moving check will work as they are under a move() command.

Any ideas?

Thanks!

steptoe

Hi

Are you using FOLLOW_EXACTLY? This will cause all characters to overlap at the same location.

To have the other characters stop short of main player use:

Code: ags

cEgo.FollowCharacter(cPlayer, 5, 80);


will make character cEgo follow character cPlayer standing about 5 pixels near him and waiting for a while before he makes his move.
5 is the pixel distance character stops from player and 80 is eagerness of chars following.
Amend as required.

You can also make any player non-solid.
Code: ags

cEgo.Solid = false;

See Manual.

Hope this is useful.



Khris

The main problem here is that multiple moving entities and walkable area solidity that changes in real time is a major computational problem. Thus AGS probably won't behave like you'd expect in an ideal world.
I don't know how often AGS updates the path calculated at the time of the Character.Walk command, or if it even does that at all.

Basically, there's no straightforward way to solve this. One thing I can think of is move the units by calling the Unit.Walk(target_x, target_y) command multiple times using a timer, to force AGS to recalculate the path several times.

SMF spam blocked by CleanTalk