Merge pull request #3 from gjcampbell777/walk_button
Initial push. Implemented basic walk button
This commit is contained in:
@@ -16,11 +16,13 @@ public class PlayerController : MonoBehaviour
|
||||
public float gravity = 5.0f;
|
||||
|
||||
private bool extraJump = true;
|
||||
private float tempSpeed;
|
||||
private Vector3 moveDirection;
|
||||
|
||||
void Start()
|
||||
{
|
||||
characterController = GetComponent<CharacterController>();
|
||||
tempSpeed = speed;
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -32,8 +34,7 @@ public class PlayerController : MonoBehaviour
|
||||
if (extraJump == true)
|
||||
{
|
||||
moveDirection = moveDirection.normalized * speed; //Remove this line to make running diagonal the fastest standard run
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
moveDirection = (moveDirection.normalized * speed)/4; //Remove this line to make running diagonal the fastest standard run
|
||||
}
|
||||
|
||||
@@ -44,6 +45,15 @@ public class PlayerController : MonoBehaviour
|
||||
extraJump = true;
|
||||
moveDirection.y = 0.0f;
|
||||
|
||||
if(Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
moveDirection = (moveDirection.normalized * speed/2);
|
||||
tempSpeed = speed/2;
|
||||
} else {
|
||||
moveDirection = moveDirection.normalized * speed;
|
||||
tempSpeed = speed;
|
||||
}
|
||||
|
||||
if (Input.GetButtonDown("Jump"))
|
||||
{
|
||||
moveDirection.y = jumpSpeed;
|
||||
|
||||
Reference in New Issue
Block a user