How to make a gameobject jump smooth?

How do you make a gameobject jump smooth?

Here’s my current script:

using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Player2 : MonoBehaviour {
 
     public GameObject Player;
     public GameObject respawn;
     public Vector3 pos;
 
     // Use this for initialization
     void Start () {
         Player = GameObject.Find ("ArrowsPlayer");
         respawn = GameObject.Find ("ArrowsPlayerRespawn");
         pos = respawn.transform.position;
     }
 
     // Update is called once per frame
     void Update () {
         if (Input.GetKey (KeyCode.RightArrow)) {
             Player.transform.Translate(Vector3.right * 4.0f * Time.deltaTime);
         }
         if (Input.GetKey (KeyCode.LeftArrow)) {
             Player.transform.Translate(Vector3.left * 4.0f * Time.deltaTime);
         }
         if (Input.GetKey (KeyCode.UpArrow)) {
             
         }
     }
     void OnTriggerEnter(Collider other) {
         if (other.gameObject.name == "killzone") {
             Player.transform.position = pos;
         }
     }
 }

So I understand that you can just have this: Player.transform.Translate(Vector3.up* 4.0f * Time.deltaTime);, but that’s not very smooth. Please tell me how to make this smoother.

void Update() {
if(Input.GetKeyDown(KeyCode.UpArrow)) {
GetComponent().AddForce(transform.TransformDirection(Vector3.up) * 5);
}
}

Remember, you need to add Rigidbody to your character :slight_smile: And do you have a 2D Character? If you have 2D character you need to add Rigidbody2D to your character, and then make this script:

void Update() {
         if(Input.GetKeyDown(KeyCode.UpArrow)) {
         GetComponent<Rigidbody2D>().AddForce(transform.TransformDirection(Vector3.up) * 5);
         }
   }