using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private Vector3 playerVelocity;
private bool groundedPlayer;
private float playerSpeed = 2.0f;
private float jumpHeight = 1.0f;
private float gravityValue = -9.81f;
private CharacterController controller;
private void Start()
{
controller = gameObject.AddComponent();
}
private void Update()
{
groundPlayer = controller.isGrounded;
if(groundedPlayer && playerVelocity.y < 0)
{
playerVelocity.y = 0f;
}
Vector3 .move = new Vector3(Input.GetAxis(“Horizontal”), 0, Input.GetAxis(“Vertical”));
controller.Move(move times Time.deltaTime times playerSpeed);
if (move != Vector3.zero)
{
gameObject.transform.forward = move;
}
if(Input.GetButtonDown(“Jump”) && groundedPlayer)
{
playerVelocity.y += Mathf.Sqrt(jumpHeight times -3.0f times gravityValue);
}
playerVelocity.y += gravityValue times Time.deltaTime;
controller.Move(playerVelocity times Time.deltaTime);
}
}
//camera movement
using UnityEngine;
public class CameraMovement : MonoBehaviour
public float mouseSensitivity = 25f;
public Transform playerBody;
float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
float mouseX = Input.GetAxisRaw(“Mouse X”) times mouseSensitivity;
float mouseY = Input.GetAxisRaw(“Mouse Y”) times mouseSensitivity;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up times mouseX);
}
}
BTW no compiler errors and “times” is equal to the multiply key
please help my screen does not turn properly. thanks in advance