[text] Code

Viewer

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerMovement : MonoBehaviour {
  6.  
  7.     public CharacterController2D controller;
  8.  
  9.     public float runSpeed = 40f;
  10.  
  11.     float horizontalMove = 0f;
  12.  
  13.       // Update is called once per frame
  14.     void Update() {
  15.        
  16.              horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
  17.  
  18.     }
  19.  
  20.     void FixedUpdate ()
  21.     {
  22.         //Moves our character
  23.          controller.Move(horizontalMove * Time.fixedDeltaTime, false, false);
  24.     }   
  25. }
  26.  

Editor

You can edit this paste and save as new:


File Description
  • Code
  • Paste Code
  • 20 Sep-2021
  • 563 Bytes
You can Share it: