Motionpath adds line to the starting point by adding two new waypoints

When I add two new waypoints to my motionpath there’s also drawed a new line to the starting point(see the picture). I don’t want this line to be drawed. I only want a line between the two waypoints underneath the crane. My first thought was the problem had to do with setCycle, but in both methods setCylce is false, so it’s something else. My car also starts at the last added point how can I change this?

Method for drawing the main path:

public void drive(AssetManager assetManager, Node rootNode, Node guiNode,FlyByCamera flyCam,final Camera cam){
        pathagv = new MotionPath();
        pathagv.addWayPoint(new Vector3f(560,7,-1500));
        pathagv.addWayPoint(new Vector3f(560,7,-1560));
        pathagv.addWayPoint(new Vector3f(-560,7,-1560));
        pathagv.addWayPoint(new Vector3f(-560,7,1470));
        pathagv.addWayPoint(new Vector3f(560,7,1470));
        pathagv.addWayPoint(new Vector3f(560,7,-1500));
        pathagv.enableDebugShape(assetManager, rootNode);

        motionControl = new MotionEvent(agv,pathagv);
        motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
        guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
        final BitmapText wayPointsText = new BitmapText(guiFont, false);


        pathagv.addListener(new MotionPathListener() {

            public void onWayPointReach(MotionEvent control, int wayPointIndex) {
                if (pathagv.getNbWayPoints() == wayPointIndex ) {
                    wayPointsText.setText(control.getSpatial().getName() + "Finished!!! ");
                } else {
                    wayPointsText.setText(/*control.getSpatial().getName() +*/ " Reached way point " + wayPointIndex);
               wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
//        chaser = new ChaseCamera(cam,agv);     
      //   chaser.setEnabled(false);
      //  chaser.registerWithInput(inputManager);
 //     initInputs(inputManager);  

Method to add two new points


public void addAgvParkings(){
parking1 = new Vector3f (535,7,1465);
parking2 = new Vector3f (535,7,1475);



In the first part of the code your first way point has the same coordinates as your last way point.

The lines are drawn between each points…So what’s actually going on is that there is a line drawn between your LAST waypoint and the new one you add.
That’s an intended behavior.

How can I solve my my problem? If MotionPath doesn’t work for what I want, what are other ways to solve it?

What do you want? Still pretty vague to me.

I want 6 points underneath each crane where the car can stop. The most right line is the main road, the main road also runs through under all the cranes. The 6 points under each crane have to be connected with the main road. When I use motion path there’s also a line drawn to the start (because a line is drawn to the first and the last added waypoint, see the picture). How to solve this problem, maybe it’s not possible with MotionPath and there’s another way to solve my problem?

You just want this lines drawn or do you want to actually make the car follow the path?
A path cannot be interrupted else it’s 2 paths.
If you want only the drawing, look how the debug rendering of the path is done and make your own.

The car has to follow the path. How to do that? So not only the drawing.