Trying to get a bool deactivated after each other bool.

Trying to get goingLeft to become the opposite after jumped becomes true. So it is like after you jump, you go the opposite direction [The whole point of goingLeft is to show what direction you are going. Kind of weird] Thanks in advance!

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

public class PlayerController : MonoBehaviour
{

public float jumpForce;
public float Speed;
public bool grounded;
public bool jumped;
public bool goingLeft;
public GameObject Player;
public Rigidbody2D rb;
public State state;

public enum State
{
    normal,
    jumping,
   
}


// Use this for initialization
void Start()
{

    rb = GetComponent<Rigidbody2D>();
    goingLeft = true;
    jumped = false;

}

void Update()
{

    if (jumped)
    {
        if (goingLeft)
        {
            goingLeft = false;
            jumped = false;

        }

        if (!goingLeft)
        {
            goingLeft = true;
            jumped = false;

        }

    }

    if (goingLeft)
    {
        rb.AddForce(transform.right * -Speed);

    }
    else
    {
        rb.AddForce(transform.right * Speed);

    }

    if (grounded && Input.GetMouseButtonDown(0))
    {
        Jump();
        state = State.jumping;
        jumped = true;

    }

forgot the whole ending [Not sure if it matters]

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

public class PlayerController : MonoBehaviour
{

public float jumpForce;
public float Speed;
public bool grounded;
public bool jumped;
public bool goingLeft;
public GameObject Player;
public Rigidbody2D rb;
public State state;

public enum State
{
    normal,
    jumping,
   
}


// Use this for initialization
void Start()
{

    rb = GetComponent<Rigidbody2D>();
    goingLeft = true;
    jumped = false;

}

void Update()
{

    if (jumped)
    {
        if (goingLeft)
        {
            goingLeft = false;
            jumped = false;

        }

        if (!goingLeft)
        {
            goingLeft = true;
            jumped = false;

        }

    }

    if (goingLeft)
    {
        rb.AddForce(transform.right * -Speed);

    }
    else
    {
        rb.AddForce(transform.right * Speed);

    }

    if (grounded && Input.GetMouseButtonDown(0))
    {
        Jump();
        state = State.jumping;
        jumped = true;

    }

   

}

void Jump()
{
    rb.AddForce(transform.up * jumpForce);
  

}

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.transform.tag == "Ground" && state ==  State.jumping)
    {
        state = State.normal;

    }

  

        }


        }

Where are changing the bool ‘grounded’?

And how about instead of doing this:

if (jumped)
     {
         if (goingLeft)
         {
             goingLeft = false;
             jumped = false;
         }
         if (!goingLeft)
         {
             goingLeft = true;
             jumped = false;
         }
     }

You can do this:

if (jumped)
{
       goingLeft = !goingLeft;
       jumped = false;
}

Since this way it will take the current value of ‘goingLeft’ bool and apply NOT to it hence inverting it every time you jump. This will make your code look clean too.

But there is one thing though, I’m still not sure what else is wrong with your code except no assignment of ‘grounded’ bool.