Hi!
I'm trying to learn how to automatically animate the camera movement. I want to add an effect where the camera animates into the scene before the actual game starts. How is this done smoothly ?
Any examples?
Thanks
Hi!
I'm trying to learn how to automatically animate the camera movement. I want to add an effect where the camera animates into the scene before the actual game starts. How is this done smoothly ?
Any examples?
Thanks
I'm guessing that by animation you mean translation/rotation (i.e. moving the camera about) over time.
Really it sort of depends on how complicated you want the "animation" to be, but ultimately should be no different than moving any other object around. Each frame move/rotate the camera toward it's target.
Do you have some more details as to what your trying to accomplish?
I'm really new at this.
I would like to move and rotate the camera from a starting point to an ending point.
Something of a zoom effect. First the object is zoomed out and then the camera zooms in and rotates a little around the object to finally stop.
That's about it.
class CameraControlState
{
abstract void update(Camera camera, double dt);
}
class FollowCameraControlState extends CameraControlState
{
void update(Camera camera, double dt)
{
// logic for follow camera
}
}
class AnimationCameraControlState extends CameraControlState
{
void update(Camera camera, double dt)
{
// logic for animating camera
}
}
class Camera
{
CameraControlState controlState;
void update(double dt)
{
controlState.update(this, dt);
}
}
// then to use it somewhere in the code
Camera camera = new Camera();
camera.setControlState(new FollowCameraControlState(cameraTarget));
// then to start a cutscene
camera.setControlState(new AnimationCameraControlState(animationKeyframes));
Implementing that may be an overkill for you current project but I am throwing it out there for consideration. Doing the camera (and player) control like this makes it extremely flexible. You can add a first person view, a fixed camera, a top down camera, a follow camera, and any other idea you may have easily. Just add another class, you don't need to touch any of the camera code and you don't end up with monstrous switch statements everywhere in your code that are difficult to maintain.