Home>
I want to jump
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement: MonoBehaviour
{
    public float m_Speed;
    public float m_Jumpheight;
    private float m_velocityY;
    private bool space = Input.GetKeyDown (KeyCode.Space);
    public GameObject player;
    Rigidbody2D m_rigidbody2D;
    Vector2 m_Vector2;
    private void Start ()
    {
        m_rigidbody2D = GetComponent<Rigidbody2D>();
        m_velocityY = m_rigidbody2D.velocity.y;
    }
    private void FixedUpdate ()
    {
        float horizontal = Input.GetAxis ("Horizontal");
        m_Vector2 = new Vector2 (horizontal * m_Speed, m_rigidbody2D.velocity.y);
        m_rigidbody2D.velocity = m_Vector2;
        if (space)
        {
            m_rigidbody2D.velocity = Vector2.up * m_Jumpheight;
        }

        if (horizontal>0)
        {
            PlayerTurn (true);
        }
        else if (horizontal<0)
        {
            PlayerTurn (false);
        }
        void PlayerTurn (bool positivOR negativ)
        {
            if (positivORnegativ)
            {
                this.transform.rotation = Quaternion.Euler (0f, 0f, 0f);
            }
            else if (! positivOR negativ)
            {
                this.transform.rotation = Quaternion.Euler (0f, 180f, 0);
            }
        }
    }
}

I'm making a side-scrolling action, but I don't know how to write the jump behavior.
It may be a simple question, but could you please tell me?

Use Ver: Unity 2019.4.12f1 Personal