Hello when i press Z the player go forward, but when i press a,d,s the camera glitch, and when i press space bar nothing appen.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public Vector3 playerVelocity;
public float playerSpeed = 12f;
public float playerSpeedGravity = 2.0f;
public float PlayerGravityValue = -9.81f;
public float playerJumpHeight = 1.0f;
public bool playerIsGrounded;
// Update is called once per frame
void Update()
{
// movement of the player.
float x = Input.GetAxis(“Horizontal”);
float z = Input.GetAxis(“Vertical”);
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * playerSpeed * Time.deltaTime);
//gravity of the player
playerIsGrounded = controller.isGrounded;
if (playerIsGrounded && playerVelocity.y < 0)
{
playerVelocity.y = 0f;
}
Vector3 Move = new Vector3(Input.GetAxis(“Horizontal”), 0, Input.GetAxis(“Vertical”));
controller.Move(move * Time.deltaTime * playerSpeedGravity);
if (move != Vector3.zero)
{
gameObject.transform.forward = move;
}
// Changes the height position of the player…
if (Input.GetButtonDown(“Jump”) && playerIsGrounded)
{
playerVelocity.y += Mathf.Sqrt(playerJumpHeight * -3.0f * PlayerGravityValue);
}
playerVelocity.y += PlayerGravityValue * Time.deltaTime;
controller.Move(playerVelocity * Time.deltaTime);
}
}