some issues with a c# jumping code in unity

some issues with a c# jumping code in unity

This the code I am having issues with, in fact when I press the space button, the player will just repeat the animation of jump and even the right arrow doesn't work anymore.

This the code I am having issues with, in fact when I press the space button, the player will just repeat the animation of jump and even the right arrow doesn't work anymore.

Please if you could help you will be more than welcome

using System.Collections;
using System.Collections.Generic;

using UnityEngine;

public class Player : MonoBehaviour { Rigidbody2D rb2d; public float Speed = 30f; public float JumpForce = 30f; bool Jump; float speed; private bool FacingRight;

// Start is called before the first frame update
void Start()
{
        FacingRight = true;
        rb2d = GetComponent<Rigidbody2D>();
        rb2d.velocity = Vector2.zero;        
}

// Update is called once per frame
void Update()
{
    if (Input.GetKey(KeyCode.Space))
    {
        GetComponent<Animator>().SetBool("Jump", true);        
    }

    if (Input.GetKey(KeyCode.RightArrow))
    {        
        GetComponent<Animator>().SetFloat("speed", 1);
        rb2d.velocity = Vector2.right * Speed * Time.deltaTime;                    
    }

    if (Input.GetKey(KeyCode.LeftArrow))
    {
        GetComponent<Animator>().SetFloat("speed", 1);
        rb2d.velocity = Vector2.left * Speed * Time.deltaTime;                   
    }
    else
    {
        GetComponent<Animator>().SetFloat("speed", 0f);
        rb2d.velocity = Vector2.zero;                  
    }

}

private void FixedUpdate()
{
    float horizontal = Input.GetAxis("Horizontal");
    Flip(horizontal);
}

private void Flip (float horizontal)
{
    if (horizontal > 0 && !FacingRight || horizontal < 0 && FacingRight)
    {
        FacingRight = !FacingRight;
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;
    }
}

 void OnCollisionEnter2D(Collision2D col)
{
    if (col.gameObject.name ==" Front_Buildings")
    {
        GetComponent<Animator>().SetBool("isGrounded", true);
        rb2d.velocity = Vector2.zero ;      
    }              
}       

}


c-sharp unity visual-studio game-development

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Top C# Development Companies & Developers Reviews

Get in touch with the most sought after C# development service providers in the web and application development industry through TopDevelopers. Among the huge number of C# developers, we have sorted the best C# service providers by their satisfied...

ludo game development.ludo game development company.ludo king game app development

We are here to bridge your dreams to reality by offering you the best ludo game development. Our Ludo game software development is the best option to choose if you want to launch a game like ludo king in a short time.

Modern C++ development with Visual Studio

Join us for a demo packed session on the latest improvements in Visual Studio 2019, including new C++20 features, cross-platform CMake integration, and support for Visual Studio Codespaces.

Rummy Game Software Development

Rummy Game Software Development- Mobiweb Technologies is India's leading Rummy Game Software provider company having expertise in providing Rummy website and app development solutions.