MovementEvent - continue from actual position/direction

after the help i got from last time, i was able to make the airplanes move in the correct direction. but i have one small problem.
what i am trying to make is a turn based game, where the player can make the number of steps equal to his speed. after each step, player can turn his airplane by 60 degrees. for most of the part it works great, but for turn after the last step, i had to add another waypoint. that makes the airplane turn halfway while reaching the waypoint. then the next player moves his airplane.
when the first player moves again, the new motionevent starts, but the airplane is flying directly to next waypoint, so there is a small jump in rotation. what is the best solution?
i tried to create separate motionevent for each player and pause the movement, but could not make that work…

You could try adding a couple way points at the beginning of the motion path: one where the plane currently is, and the other a little offset from the plane in the direction the plane is facing.

i am using waypoints to update location of the moving airplane, so i would like to avoid adding waypoints. i am trying to pause the movement, but at the next turn it does not stop, when it should and makes one more step.

    private void Move(){
        //actplane = mainScene.getChild(activePlane.getName());
        
        activePlane.path.addListener(new MotionPathListener() {
        
            @Override
            public void onWayPointReach(MotionEvent control, int wayPointIndex) {
                waypoint++;
                    Waypoint wp = mm.paths.get(pathIndex).getWP(waypoint);
                    activePlane.update(wp.getdirchange());
                    activePlane.motionControl.pause();
                    activePlane.path.disableDebugShape();
                    airplanemoves = false;
                    activePlane.setWaypoint(wayPointIndex);
                    endTurn();
                } 
                if (activePlane.speed>waypoint){
                    //here updating map position of airplane
                    Waypoint wp = mm.paths.get(pathIndex).getWP(waypoint);
                    
                    activePlane.update(wp.getdirchange());
                }
                if (activePlane.speed<waypoint){
                   //only here to check if motion stops
                    System.out.println("Why didnt it stop at previous step???");
                }
            }
        });

i am quite lost when it comes to moving anything along the path. pausing and continuing movement did not work as i wanted to… even when i tried to erase the duplicate waypoints and continue the movement, the move started where the previous should ended (at last waypoint) and not where it was paused (one waypoint before the last one)
so i have just a few simple questions.

    • is it possible to skip a waypoint? for fluent movement i would need to have set a waypoint from where the airplane was flying in previous step, but i didnt find a way to do this. - at least that is one way i can think of…
    • is it possible to set the up direction for a waypoint, so the airplane would roll a few degrees in turns? (if not, maybe i will try to create another path with invisible object that the airplane would be looking at)
      if there is a better solution, i would like any hint i can get. the way it is set now, the airplane follows the path, but when i try to set the path to do a loop, it flips in top position so the top of the plane is up, instead down…

Sorry for the late reply. :stuck_out_tongue:

  1. No, it’s not possible to skip a waypoint. The waypoints define the curve, so to have the curve “skip one,” you’d have to delete that waypoint from the curve altogether.

  2. I’m not sure. You’d have to look at the methods provided.

MotionPath is intended for predictable cinematic motion, so you’re kinda abusing it by using it for game logic. Perhaps you would have an easier time if you coded your own motion system.

2 Likes

This.

It sounds very much like OP wants a waypoint steering solution and not prebuilt cinematics.

What code are you using to stop the player (or plane) from moving? Because motion in physics is inertial, you have to remove all the forces to get it static…, so I guess your problem might be here…

According to OPs questions, they are not using physics but cinematics.

MotionEvent is a cinematic class. (MotionEvent (jMonkeyEngine3))

there is no physics involved in movement… just the motionEvent and waypoints. one waypoint before the end of path i am using the stop or pause commands. tried the pause, hoping i would be able to continue the movement instead of starting a new one every time, but that did not work right, so now i am leaving it as it was.

anyway, if this movementevent thing is not suitable for what i am doing, what should i use? i dont need the moveable object to be directly controlled by players, i need them to move from hexagon to hexagon and i would like it to move on a curved line, when changing directions. the only other version of this thing i made years ago used basic java and had a really bad looking movement (airplane was flying from waypoint to waypoint in straight lines, but when turning, it was rotating to new direction, so close to checkpoint it was moving sideways)

Jme does not have a movement system specifically for this case, however, nothing is stopping you from making it yourself (in fact, that should be expected).

1 Like

Are you looking for a pattern to use? Or a specific API in Jme?

If you are asking about a specific pattern; then you can use a deterministic-finite-state automaton (or a state-machine, a very similar to Jme States, but in a directional sort of thing).

I have a generic framework, I was working on, you can try if you are searching for a specific pattern, there is a wiki also for its uses, you can define multiple states, a MOVE state and a TURN state and use them sequentially until reaching a TERRITORY state; then stop your vehicle, I guess this may logically work?:

If you don’t need a real steering system and the JME cinematics code is “almost” what you need… then you could always start by looking at that source code and pulling out just the parts you need for your stuff.

When I referenced a “simple steering” system it would solve your problem dynamically without having to precreate paths or anything. The object would steer some amount of left or right to get to the target object and would make nice smooth curves. The only issue is that it is meant for real time steering (like from an AI) and may take some iterations to tune the parameters to not do dumb looking things like overshooting your targets and turning around to come back.

It will also take as long as it takes… where as a motion path you can force to take a specific amount of time even if it makes the object fly really fast over that path. A steering system will only move the object within the parameters of movement (max acceleration, max speed, max turn speed, etc.)

However, once tweaked a steering system will handily deal with any starting direction and target without calculating motion paths or any of that sort of thing.

(And they are kind of fun to play with.)

1 Like