2021-07-19 11:45:08 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class PlayerControls : MonoBehaviour
|
|
|
|
{
|
2021-07-19 19:27:02 +02:00
|
|
|
public CharacterController2D controller;
|
|
|
|
public float runspeed = 40f;
|
|
|
|
float horizonatalmove = 0f;
|
|
|
|
bool jumping = false;
|
|
|
|
bool crouching = false;
|
2021-07-19 11:45:08 +02:00
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
2021-07-19 19:27:02 +02:00
|
|
|
horizonatalmove = Input.GetAxisRaw("Horizontal") * runspeed;
|
|
|
|
jumping = Input.GetButton("Jump") || Input.GetAxisRaw("Vertical") > 0;
|
|
|
|
crouching = Input.GetButton("Crouch") || Input.GetAxisRaw("Vertical") < 0;
|
2021-07-19 11:45:08 +02:00
|
|
|
|
2021-07-19 19:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FixedUpdate(){
|
|
|
|
controller.Move(horizonatalmove * Time.fixedDeltaTime, crouching, jumping);
|
|
|
|
|
2021-07-19 11:45:08 +02:00
|
|
|
}
|
|
|
|
}
|