BGP #3

Welcome back to Causality!

Today I will talk about what have happend during week 3 while working on Causality so this time I will focus on how I got our camera to look at the enemies from behind the player using my own function the lock on. . When working on the lock on function for the camera I cooperated with my lead programmer.

We wanted to be able to lock the camera behind the player so the player could face the boss and so you could see the boss properly during the fight if you wished. So we began by implementing an old script coded from a tutorial which was used to follow behind the player made by another programmer in our team however as the camera needed to be behind the player and still facing the boss boss.

So to begin with we used a unity function called LookAt. LookAt set the facing direction towards the object sent in through a paramenter in the function, Then we had to set the position behind the player which became problematic because we didn’t understand how but I finally figured out a simple solution.

First I tried to use vector math to set the position from the boss to the player and then further, but this became complicated real fast. So after brain storming about it for a while I came up with the idea to take the player position minus the cameras forward direction from a unity function. Now it would be at the player and all we had to adjust was how far behind the player it needed to be using multiplication on a constant variable.

Now we updated the camera’s rotation with unitys LookAt function and the camera’s position with help of the the players position and cameras facing direction. Then we activated it on and off with a button press and a bool check.

Bool check is a on or off check.

About Christoffer Lövdahl

2015 Game Design