Sunday, 15 February 2015

Spring Project - Player Movement Scripting

The second task of this week was the creation of player movement scripts to allow the player to control both the camera and the character in a 3D space. I was easily able to create this movement on the x and z axis as this was basically a normal character motor using the application of the inbuilt unity inputs. However our game requires the use of all 3 axis so as to simulate the feeling of swimming and to not restrict the ability to swim up or down. This presented a whole host of problems for me to overcome. Originally I just created a 3rd input axis and tapped into that but the character could only move on its global axis even when parented to look at another target. Therefore I started tapping into the transforms of the object and used that to move the controller around. However this meant the player would retain motion from hitting into things even if the player was not actively  creating any input. Therefore I created a secondary part of the script to turn the ridigbody kinematic on and off to null any momentum at the moment no inputs are detected. This is most likely a very roundabout method and I shall be editing the script as I see fit. But it remains a strong starting point as it stands and can be used in the final game if the need arose.

No comments:

Post a Comment