Why is shooting and jumping very rarely reproduced in my code?

using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private float speed = 5f;
    private float mouseX;
    private float jumpVelocity = 5f;

    public float distanceToGround = 0.1f;
    public LayerMask groundLayer;

    public GameObject bullet;
    private float bulletSpeed = 100f;

    private Rigidbody rb;
    private CapsuleCollider coll;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        coll = GetComponent<CapsuleCollider>();
    }

    void FixedUpdate()
    {
        if (isGrounded() && Input.GetKeyDown(KeyCode.Space))
        {
            rb.AddForce(Vector3.up * jumpVelocity, ForceMode.Impulse);
            print("Jump");
        }
        MovementLogic();
        if (Input.GetMouseButtonDown(0))
        {
            GameObject newBullet = Instantiate(bullet,
               transform.position + new Vector3(1,0,0),
               transform.rotation) as GameObject;
            Rigidbody bulletRb = newBullet.GetComponent<Rigidbody>();

            bulletRb.velocity = transform.forward * bulletSpeed;
        }
    }
    private void LateUpdate() 
    {
        RotateLogic();
    }
    private void RotateLogic()
    {
        mouseX = Input.GetAxis("Mouse X") * 2;
        transform.Rotate(mouseX * new Vector3(0, 1, 0));
    }
    private void MovementLogic()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

        transform.Translate(movement * speed * Time.fixedDeltaTime);

    }
    private bool isGrounded()
    {
        Vector3 capsuleBottom = new Vector3(coll.bounds.center.x,
            coll.bounds.min.y, coll.bounds.center.z);
        bool grounded = Physics.CheckCapsule(coll.bounds.center, capsuleBottom,distanceToGround,groundLayer,QueryTriggerInteraction.Ignore);
        return grounded;
    }
}

My project is not very heavy and mayby the problem is not in optimizations.
But im waiting youre suggestions :yum:

Because you need to check Input states in Update() staying physics logic in FixedUpdate().
You can achieve this with boolean variables.

Yeah, to be clear, Input is processed in Update. So doing it in FixedUpdate will miss events.

Yep, GetKeyDown and GetMouseButtonDown are supposed to be used in Update. They’re unreliable if used in FixedUpdate.

Also, on line 61 you’re moving a rigidbody with transform.Translate. Instead you should use:

rb.AddRelativeForce(movement * speed);

Thank you guys, you helped me a lot, thank you everyone for your responsiveness and explanations! :blush:
Everything works well for me now, I went to finish my project!