JacopoLevati-Creator 61822e8ca9 commit
2025-03-12 19:33:06 +01: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);
}
}
}