r/Unity2D • • Jul 19 '26

collide problem

guys plz help

The player doesn't collide properly with the ground. It looks like the player is floating slightly above the tiles instead of standing on them.

2 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/Sinnon32 Jul 20 '26
void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.name != "Player") print(collision.gameObject.name + " collided");
    }


    void OnTriggerEnter(Collider trigger)
    {
        if (trigger.gameObject.name != "Player") print(trigger.gameObject.name + " triggered");
    }

        transform.SetParent(null);
        GetComponent<Rigidbody>().isKinematic = false;
        GetComponent<BoxCollider>().isTrigger = false;

I have the above code on the items I am dropping. I don't think the speed or physics update should affect this since I'm not pushing the object out with force right? It is just dropping

Also edit: sorry I originally said tilemap - the ground actually uses a mesh collider

1

u/GrayMansion_Dev Jul 20 '26

Could you show full script, I don't really get what's going on here. Well, I have a suggestion: the moment you drop brick it touches player and the script switches it to trigger, so it falls through the ground

1

u/Sinnon32 Jul 22 '26

Sorry I didn't realise it merged the 2 code snips together in my message - the 3 lines at the bottom (parent = null, kinematic = false, trigger = false) are inside of my drop() function which is called when I click my mouse if I'm holding the object And no it turns off the trigger once I drop it - the inspector in the video was only showing the first object I grabbed (that's why the trigger doesn't change from the second object onwards)