Inspect System

In the game "Stilla Natt" we wanted to give the player the ability to closer inspect and interact with items in the world. To achieve this, we set out to find a reference game to help us find the right feel for our game. We decided on using Resident Evil 2 as a reference.

First thing first, I wanted the camera to center on the inspected object. This was done with a simple "look at" function from our math library. First, I check all objects in range. I then use the dot product of the camera forward vector and "from camera to object"-vector to decide which object is closest to the camera center (where the player is looking). To determine if the object is in line of sight (so it's not behind a wall or some other object) I use a physX ray trace from the camera to the object, sort all overlaps by distance, and check if the closest object is the same as the object we want to inspect.

Next thing to get done was the ability to rotate items. The rotation needed to be relative to the camera. This was done by saving the inspected objects initial transform, creating a rotation matrix with the desired rotation using the camera transformation matrix as a point of reference, and multiplying the matrices in the correct order before replacing the objects matrix with this new one.

Then I added a simple zoom in/out. Nothing fancy, but it'll get the job done!

Adding support for Level Designers to chose where to put camera and flashlight when inspecting.

To make it look better I added SLERP/LERP for camera rotation and position.

Now we want to be able to interact with the inspected item! This is done by ray tracing in a straight line starting from the camera, going through cursor position in world, and hopefully hitting something we can interact with. If the player interacts with a valid object, or part of object, we call the correct script for that object. All events fired through this interaction in fully scriptable by our Level Designers through our Node Editor!