Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class P1PlayerMovement2D : MonoBehaviour
- {
- public P1CharacterController2D controller;
- public float runSpeed = 40f;
- float horizontalMove = 0f;
- bool jump = false;
- bool crouch = false;
- // Update is called once per frame
- void Update()
- {
- horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
- if (Input.GetButtonDown("Jump"))
- {
- jump = true;
- }
- if (Input.GetButtonDown("Crouch"))
- {
- crouch = true;
- }
- else if (Input.GetButtonUp("Crouch"))
- {
- crouch = false;
- }
- }
- void FixedUpdate()
- {
- // Move our character
- controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
- jump = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement