I’m sorry to have to ask another similar question, but I’ve been trying this for hours with no success.
I simply want to have a rotation animation (as controlled by a AnimationControl [build from AnimationFactory], and MotionPath animation playing at the same time.
In the past, I have used a Cinematic to do this, so that’s what I thought I’d use. However, if I try to get them to play together I just get that same old IndexOutOfBoundsException: Index: 4, Size: 4 which I have discussed in previous topics.
I have tried repositioning lines of code, because I know that in the past it has been due to initialization, but this has not worked. I have played around with calling [java]motionEvent.play();[/java] and removing it from the cinematic. I have also tried calling [java] rotAnimControl.createChannel().setAnim(“vehicleRot”); [/java] and removing it from the cinematic. If I do both of these together, the MotionEvent is ignored, and only the rotation animation plays, but it loops constantly.
I had the MotionEvent working on its own just fine. But I need rotation to complement it, and I would like to keyframe the rotation, as opposed to have it looking at another spatial.
The full error:
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] java.lang.IndexOutOfBoundsException: Index: 4, Size: 4 at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at com.jme3.math.Spline.interpolate(Spline.java:288) at com.jme3.cinematic.MotionPath.interpolatePath(MotionPath.java:94) at com.jme3.cinematic.events.MotionEvent.onUpdate(MotionEvent.java:199) at com.jme3.cinematic.events.MotionEvent.setTime(MotionEvent.java:195) at com.jme3.cinematic.Cinematic.onStop(Cinematic.java:180) at com.jme3.cinematic.events.AbstractCinematicEvent.stop(AbstractCinematicEvent.java:158) at com.jme3.cinematic.events.AbstractCinematicEvent.internalUpdate(AbstractCinematicEvent.java:138) at com.jme3.cinematic.Cinematic.update(Cinematic.java:320) at com.jme3.app.state.AppStateManager.update(AppStateManager.java:287) at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239) at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151) at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228) at java.lang.Thread.run(Thread.java:744)
Code for running the two animations:
Cinematic rotCinematic = new Cinematic(gW.getGameWorldNode(), 1);
//LOCATION MotionPath path = new MotionPath(); path.addWayPoint(peerNode.getLocalTranslation()); path.addWayPoint(newPos); path.setCurveTension(0.5f); MotionEvent motionEvent = new MotionEvent(peerNode, path); motionEvent.setSpeed(1f); motionEvent.setInitialDuration(delay); motionEvent.setLoopMode(LoopMode.DontLoop); //motionEvent.play(); //ROTATION AnimationFactory factory = new AnimationFactory(delay, "vehicleRot"); factory.addTimeRotation(0, peerNode.getLocalRotation()); factory.addTimeRotation(delay, peerRotation); final AnimControl rotAnimControl = new AnimControl(); rotAnimControl.addAnim(factory.buildAnimation()); peerNode.addControl(rotAnimControl); rotCinematic.addCinematicEvent(0, new AnimationEvent(peerNode, "vehicleRot", LoopMode.DontLoop)); rotCinematic.addCinematicEvent(0, motionEvent); [/java]