Issues with navigator

Dec 11, 2012 at 1:03 AM

Hi,

I'm having an issue getting the basic steering behaviors working correctly in 1.4. When using the Navigator.MoveTo() method I can get the unit to move correctly along the the X axis but it seems to get stuck moving along the Z axis and also faces the wrong way.

Have there been updates the steering library since the Y became the up axis? Could this be the issue or is it something in my code? I had basic samples working in the previous version of Nine so I'm not sure what I'm doing wrong.

// Call to UnitController      
private void MoveTo(int destination)
{
     var dest = graph.IndexToPosition(destination);

      controller.MoveTo(new Vector3(dest.X, dest.Y, 0));
}

// UnitController
public void MoveTo(Vector3 pos)
{
    Navigator.Stop();
    Navigator.MoveTo(pos);
}

protected override void Update(TimeSpan elapsedTime)
{
    Navigator.Update(elapsedTime);

    model.Transform = Matrix.Identity * Navigator.Transform;

    base.Update(elapsedTime);
}

Coordinator
Dec 11, 2012 at 1:56 AM
Edited Dec 11, 2012 at 8:58 AM
Sorry to say that the navigation lib was not updated with the graphics lib. Physics and navigation are not as mature as graphics :'(
Dec 11, 2012 at 3:33 AM

OK fair enough. I thought I should check before I spend time looking into the issue.

Do you have a road map for when these components will be updated?

Developer
Dec 11, 2012 at 8:35 AM

http://nine.codeplex.com/wikipage?title=Roadmap%20%26%20Visions

:-9

Dec 14, 2012 at 2:53 AM
Edited Dec 14, 2012 at 3:40 AM

Hi,

I had a bit of a poke around into the steering code and realised that since the actual steering logic is all in 2D it must just be an issue converting to 3D space. It turned out to be the object facing translation that was causing the problem.

In the Navigator::Update method I changed:

Vector3 facing = new Vector3(steerable.Forward, 0);

To:

Vector3 facing = new Vector3(steerable.Forward.X, 0, -steerable.Forward.Y);

That seemed to fix the issue for me. I haven't tested much except with basic Seek behavior on flat terrain but just thought I would let you know.

Edit - also had to update the rotation offset logic:

 

float rotationOffset = (float)Math.Atan2(facing.Y, facing.X) - Rotation;
to:
float rotationOffset = (float)Math.Atan2(facing.Z, facing.X) - Rotation;

 

 

Coordinator
Dec 14, 2012 at 4:07 AM

Thanks for the help!!

Dec 14, 2012 at 4:46 AM

The one thing I'm not too sure about though is why I had to flip the Z axis to a negative value. The positive Z axis should have been the same as the old Y value right? So maybe I'm missing something...

Coordinator
Dec 14, 2012 at 5:30 AM

It's because the Y axis for the heightmap has flipped.