BGP #2
|
Welcome back to Causality! Today I will talk about what I accompliced this week by focusing on my work with the camera in our game and how it affects the use of movement in our game. We began by using a unity’s transform function called LookAt which changes the rotation of the camera to face an object, the object was the player then rotate the camera around the player by changing it position with the controller in a sphere. So now instead of moving around using the world position we needed to change the movement depending on the camera’s position all to prevent the player from getting disoriented and making the controls easy to understand. To have the character move according with the camera I began by getting the input from the controller using conde and unitys input manager then making a function that returns a normalized vector . The functions return a vector with the direction to rotate the player towards then I had to changed the vector by the camera’s rotation so i could get the rotation for the players facing and then I had to move the player in that direction using unitys forward functions that moves the player in the Z angle (0,0,1). The forward function gives a normalized vector of the currents objects facing rotation then I used unitys rigidbody component to move position function. Normalize keeps the value between 0 and 1. The reason I used the rigidbody move function is to let the player use unitys physics engine. |