Advertisement
ItsMeLucifer

UNITY Player Movement with CharacterController

Oct 18th, 2021
1,227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerMovement : MonoBehaviour
  6. {
  7.     private CharacterController characterController;
  8.     public float speed = 0.05f;
  9.     void Start()
  10.     {
  11.         characterController = GetComponent<CharacterController>();
  12.     }
  13.     void Update()
  14.     {
  15.         Vector3 inputMovement = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
  16.         characterController.Move(inputMovement * speed * Time.deltaTime);
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement