My player character has a rigidbody but the addforce function is not making the character move. ive tried putting it in the FixedUpdate and the normal Update.
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed;
private float maxSpeed = 6;
private Vector3 input;
void Start()
{
}
void FixedUpdate()
{
if(GetComponent().velocity.magnitude < maxSpeed)
input = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
GetComponent().AddRelativeForce(input * moveSpeed);
}
}
,
↧