using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public Transform groundCheckTransform;
private bool jumpKeyWasPressed;
private float horizontalInput;
private float verticalInput;
private Rigidbody rigitbodyComponent;
public LayerMask playerMask;
// Start is called before the first frame update
void Start()
{
rigitbodyComponent = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
jumpKeyWasPressed = true;
}
horizontalInput = Input.GetAxis("Horizontal");
verticalInput = Input.GetAxis("Vertical");
}
private void FixedUpdate()
{
rigitbodyComponent.velocity = new Vector3(horizontalInput * 10, rigitbodyComponent.velocity.y, verticalInput * 10);
if (Physics.OverlapSphere(groundCheckTransform.position, 0.1f, playerMask).Length == 0)
{
return;
}
if (jumpKeyWasPressed)
{
rigitbodyComponent.AddForce(Vector3.up * 8, ForceMode.VelocityChange);
jumpKeyWasPressed = false;
}
float moveHorizontal = Input.GetAxisRaw("Horizontal");
float moveVertical = Input.GetAxisRaw("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
transform.rotation = Quaternion.LookRotation(movement);
transform.Translate(movement * 5 * Time.deltaTime, Space.World);
}
}
internal class SerializedFieldAttribute : Attribute
{
}
this is the first code i’ve ever written so how do i fix this