Dynamic camera for a side scroller

How can would I code a camera normally following the player the game, but at certain areas or during certain attacks have the camera switch to a more dynamic view of the player or slow down while dynamically looking at the player then switch back to normal view (as in super street fighter 4).

-would I use triggers that the player would run into (then how would I do the certain attack dynamic views)...

-would I script that when a certain event or animation is triggered...

-would I just set up a camera track (if so then how) that the camera would follow the movements...


I would suggest that you decide on (and create) the desired effect, and then worry about how and where you want to integrate it. Depending on the gameplay, more than one of your own suggestions could be valid, and then having the camera event code in its own bundle would make it easier to trigger at the appropriate times (whether by entering an area, or when playing a specific animation/combo).

To create animated cameras, you'd probably be best animating it in Maya (or similar 3D program), and playing the animation on an object, which a new camera is parented to (as described in this answer). This approach would make it much easier to sync with the character animations.

If you're after dynamic viewpoints when you enter an area, you could:

  • Create a GameObject with a Collider and isTrigger as True
  • Create a script with a Vector3 and attach to the GameObject
  • Store the desired camera position for that trigger area to the Vector3 in the script
  • OnTriggerEnter, inform the CameraManager/script that it has changed state, and should track from the new position (specified on that GameObject). You could also specify whether to blend or cut.
  • OnTriggerExit, inform the CameraManager/script that the special state has ended, and it should return to standard tracking.

For slow motion effects, use Time.timeScale. This directly controls the scale at which time passes.

If you're inexperienced with scripting/coding, there are plenty of resources to get you started - take a look at 'How can I start learning Unity fast? (List Of Tutorials)'. For the gameplay you've described, I'd suggest you start with the 2D Gameplay Tutorial.

By the sounds of things, you don't have very much scripted yet. You should try to get a side-scrolling character and camera before worrying too much about dynamic effects. If you get stuck, search the wiki as there are a lot of posts regarding 2D gameplay and cameras.

Hopefully this will give you a decent idea of where to work towards!