So my issue today is that my cube wont accelerate properly… is there any pointers or tips I could have???
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class Player : MonoBehaviour
{
public float movementSpeed;
private float movementSpeedMaximum = 4f;
Rigidbody playerRigidbody;
Vector3 movement;
// Start is called before the first frame update
void Start()
{
playerRigidbody = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.z = Input.GetAxisRaw("Vertical");
movement = new Vector3(movement.x, 0, movement.z).normalized;
if(playerRigidbody.velocity.magnitude < movementSpeedMaximum)
{
playerRigidbody.AddForce(movement * movementSpeed);
}
}
}
