Hi,

thank you both for the infos

I have a 2 dim Array where right now each obstancle has a value>0, all empty fields have 0.

My houses may be larger or smaller than one field, and trees are smaller in every case I guess.

That's why I thought I'd combine a pathfinding with a bounding box collision detection so they always do the next step and when they collide, they got set back to last position with a new pathfinding with this field marked somehow I don't know exactly. There can also be collisions with other moving meshes/units...

This is why I have some problems here.

The moving is simple, there are some fields the villagers are randomly sent to to 'work' there. they are just moving between those fields.

The monsters later should run after the villagers and kill/eat them.

Those both should not move 'trough' houses trees etc and also not 'through' other moving units.

An approach would be enough if they make a 'large' way round the house it is okay, they just should not walk right 'through' it.

Here some code of the villagers, they now always walk the shortest way set by the starting angle to the target point.

Code:
  MeshBauer = class(TDJXSprite)
    boolstand: boolean;
    nsx,nsy,nsz,nspeed,nHOff: single;
    Radius: single;
    ntyp:       integer;
    nanimpos,nrotatey: single;
    ntargetx,ntargetz: single;
    procedure Process(SpeedFactor: single); override;
    procedure Draw; override;
  end;

procedure TForm1.add_bauer(nx,nz: single);
begin
  with MeshBauer.Create(Engine) do
  begin
    nspeed:=0.025;
    ntyp:=0;
    nsx:=0.19;
    nsy:=nsx;
    nsz:=nsx;
    x:=nx;
    z:=nz;
    get_bauerntarget(ntargetx,ntargetz);
    Radius:=15;
    nrotatey:=GetAngle(x,z,ntargetx,ntargetz);
  end;
end;

procedure MeshBauer.Draw;
var mesh: tdjxmesh;
    nanim: integer;
begin
  inherited;
  if boolstand then nanim:=0 else nanim:=1;
  mesh:=form1.MeshListBauer.Meshes[nanim];
  Form1.DanJetX1.Matrices3D.ClearWorldMatrix;
  Form1.DanJetX1.Matrices3D.ScaleWorld(nsx,nsy,nsz);
  Form1.DanJetX1.Matrices3D.MoveWorld(x,y,z);
  Form1.DanJetX1.Matrices3D.ApplyWorldMatrix;
  if mesh.IsInFrustum then mesh.render(x,y,z,0,-nrotatey-pi/2,0,nsx,nsy,nsz,round(nanimpos));
  nanimpos:=nanimpos+nSpeed*time_elapsed;
end;

procedure MeshBauer.Process(SpeedFactor: single);
var tx,tz: double;
begin
  inherited;
  if not boolstand then begin
    //Falls Entfernung geringer als Geschwindigkeit direkt ans Ziel setzen
    if Distance&#40;x,z,ntargetx,ntargetz&#41; < time_elapsed/36 then
    begin
      boolstand&#58;=true;
      form1.get_innomtarget&#40;ntargetx,ntargetz&#41;;
      nrotatey&#58;=GetAngle&#40;x,z,ntargetx,ntargetz&#41;;
    end else begin
     //Eigentliches Bewegen
     tx&#58;=x;
     tz&#58;=z;
     form1.move_forward&#40;tx,tz,nrotatey,time_elapsed/36&#41;;
     x&#58;=tx;
     z&#58;=tz;
    end;
    Y&#58;=Landscape.Altitude&#91;X,Z&#93;+0.65;
  end;
end;
Understandable? Don't care about the draw method, it is working great,
it is just how I move them now.

get_Bauerntarget just delievers the Target location to walk to.

Code:
procedure TForm1.move_forward&#40;var X, Z&#58; double; nRotate,nSpeed&#58; single&#41;;
var Dir&#58; TD3DXVector3;
begin
  Dir.X &#58;= cos&#40;nRotate&#41;;
  Dir.Z &#58;= sin&#40;nRotate&#41;;
  X&#58;=X+nSpeed*Dir.X*time_elapsed;
  Z&#58;=Z+nSpeed*Dir.Z*time_elapsed;
end;

//Berechnung der Entfernung zweier Punkte&#58;
function Distance&#40;x,y,x2,y2&#58; single&#41;&#58; Real;
begin
Result &#58;= sqrt&#40; sqr&#40;y2-y&#41; + sqr&#40;x2-x&#41; &#41;;
end;

//Winkel einer Strecke zwischen zwei Punkten&#58;
function GetAngle&#40;x, y, x2, y2&#58; single&#41;&#58; Real;
begin
Result&#58;=arctan2&#40;y2-y, x2-x&#41;;
end;
@Huehnerschaender: I am not good at C++ so I think I will not read that sample, or is it so good?

Right now they don't care about any stuff in my 2dim array, it looks like this:

TLevel=Array[0..levelb,0..levelh] of byte;

where Levelb and Levelh both are 256 currently.

Thanks a lot,
firle