I would like to make the camera shake like an earthquake is happening for a few seconds using JME3 Cinematics, but I don’t know how to do this even after reading the wiki but I have a few ideas. What I would like to know is how should I do this?
I could do something like…
// I assume the following code would only shake the camera for one second but you get the point.
for(int index = 0; index < shakePerSecond; index++) {
String camNodeName = "quake_cam_" + index;
CameraNode camNode = cinematic.bindCamera(camNodeName, cam);
float x = (float) Math.random() * shakeAmount;
float y = (float) Math.random() * shakeAmount;
float z = (float) Math.random() * shakeAmount;
camNode.setLocalTranslation(camLocation.add(x, y, z));
cinematic.activateCamera(index, camNodeName);
}
but this just seems wrong.
So is the better option to create a custom CinematicEvent extending AbstractCinematicEvent and just set the camera location in the onUpdate(float) method?
Or is there an entirely different method that I have not found for doing this?