[Project Week 9.0] Adjustments to the player

Movement system change

First thing I would like to adjust is the movement system. Right now the movement system uses something called transform.translate to move the player around, which looks fine on the system that I am running the game on (quite a solid system) however this code may not work the greatest on lets say weaker systems. So instead of the transform to move the player I will be revamping it to the physics system to get more precise movement, and it will also be better for later when I add things like collision.

For the physics system I will be adding a built in unity component called rigidbody which allows me to mess around with the physics a little, in it's default state my character will just fall to the ground because gravity is turned on but I later turn this off as it is useless is a top down 2d game:



This codes creates reference to the component I added:





Next I completely removed the previous transform move function and replaced it with this. Notice I didn't use delta time which is because I will now be using the physics system which is dependent on frame rate instead:





Note the normalized added on to the direction speed, this is to prevent my character from moving faster when pressing 2 keys at the same time, for example going diagonally would be faster than holding one key going right without the normalize.







Now I will be using a unity feature called Blend Tree which will be used to switch between animations for me:





Comments