OnTrigger Confusion.

I’m incredibly new and ignorant to unity, and to give myself a challenge I figured I’d start with a 2D platformer, figured it’d be straightforward. I’ve hit my first hitch with ground checks, I’m using OnTriggerEnter and OnTriggerExit with two box colliders on my main character, one as the trigger and the other as the physics collider. The problem I find is the trigger collider is not being recorded as colliding with anything despite it extending further than the physics collider. Without the ground checks, I can’t keep the player from being able to fly by spamming space bar. Once again, I’ve been using unity for maybe 3 months, and have no prior coding knowledge, specifics and terms may go over my head, but I’m determined to keep trying.

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

public class Movement : MonoBehaviour
{
    Animator Anim;

    public float speed;

    public Rigidbody2D rb;

    public float jumpForce = 10;

    public float gravityScale = 10;

    private bool isGrounded = false;

    private void Start()
    {
        Anim = GetComponent<Animator>();
    }
    private void FixedUpdate()
    {
        Vector3 playerInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, 0);
        transform.position = transform.position + playerInput.normalized * speed * Time.deltaTime;
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Ground")
        {
            isGrounded = true;
            Debug.Log("TriggerEnter");
        }
    }
    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Ground")
        {
            isGrounded= false;
            Debug.Log("TriggerExit");
        }
       
    }
    private void LateUpdate()
    {
        if (isGrounded = true && Input.GetKeyDown(KeyCode.Space))
        {
            rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.y);
        }
       
    }
   
}

The 2D physics callbacks have a “2D” suffix so OnTriggerEnter2D and OnCollisionEnter2D. You should also be clear that the ones you have are being passed a 3D collider (Collider) and not a 2D collider (Collider2D).

You’re using the 3D ones which won’t be called.

Also, the whole point of a Rigidbody2D is to simulate physics and write the results back to the Transform. This means you should never write to the Transform. If you want movement, use the Rigidbody2D API to do so.

There are plenty of tutorials online about this so I won’t dig any further into it.

There’s also Unity Learn which has a bunch of currated tutorials.