This repository has been archived on 2024-06-19. You can view files and clone it, but cannot push or open issues or pull requests.
evermillion/Assets/Brick Project Studio/_BPS Basic Assets/Common/Scripts and Animations/First Person Player/PlayerMovement.cs
2024-06-05 11:10:54 +08:00

37 lines
772 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace SojaExiles
{
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 5f;
public float gravity = -15f;
Vector3 velocity;
bool isGrounded;
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
}
}