Nuclear Throne-style Camera Follow and Shake.

I've recently been recommended this excellent top-down roguelike shooter, Nuclear Throne, available on Steam. It has a very nice camera shake functionality that I would like to share my Unity3d(C#) recreation of.

Nuclear Throne, Level 1

How [I think] it works

It takes the world or screen position of the player and that of the cursor/mouse, subtracts them then normalizes them to create a 2d vector by which they offset the camera's position on the x and y axes. The intensity of the explosion or gunshot determines the intensity of the displacement.

Here is a standalone version of the shake code:

I also provide below a more complete script that includes target follow functionality.

#nuclearthrone #retro #pixel #game #videogame