Sunday, December 13, 2015

New aiming system

The old aiming system was very imprecise. The camera have different offsets and the character aiming postures are no perfect. So the alignment had errors.

This new method are using "canvas.project" to find exact values to pass to aim node.

Instead comparing character and camera rotations, I do a projection of the weapon canyon over the screen, and compare it with the center. After that is easy to find the values for the aimnode.

No matter if the aiming postures aren't perfect, the system always finds the weapon correct orientation with respect to crosshair in the center of the screen (in the video there are a little "lag" because it's using interpolation for smooth movements).

Also the player auto-rotates when the horizontal aim is near the limit.

In the video you can see a red "laser guide", a debug line that is the current weapon orientation. Always finishes in the crosshair, what is the desired.

This is using UDK, but it can work with UE4 and any engine, only need some function to convert 3D coordinates to 2D (canvas.project in UDK).

The weapon are only for tests purposes, downloaded from In the final game will be bows and crossbows.

More detailed and code here:

1 comment: