Here’s my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public Rigidbody Player;
public int Force = 50;
// Update is called once per frame
void Update () {
{
if (Input.GetKey (KeyCode.UpArrow))
Player.AddForce (0, 0, Force * Time.deltaTime, ForceMode.VelocityChange);
else
Player.velocity = Vector3.zero;
}
{
if (Input.GetKey (KeyCode.DownArrow))
Player.AddForce (0, 0, -Force * Time.deltaTime, ForceMode.VelocityChange);
else
Player.velocity = Vector3.zero;
}
}
}