Problems with using OnCollisionEnter

Hi, im in the 19th Class of the 3D course and im trying to use OnColissionEnter according to the instructions, but even having carried out each of the indications, my character keeps breaking through the walls. I checked the following thinks:

-Every wall has its Mesh Renderer and Box Collider activated
-Every wall has the script “ObjectHit” added in its components
-My character has its Mesh renderer and Box Collider activated

The script ObjectHit has the next content:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class ObjectHit : MonoBehaviour


private void OnCollisionEnter(Collision other)


        Debug.Log("You re bumping a wall!");



could there be something i’m forgetting?

Hi @walton_muller,

What you described sounds fine. Given the player has got a Rigidbody and a Collider attached, I doubt that you forgot something. Try to make the player slower. If it’s moving too fast, it might get pushed through the colliders.

1 Like

Thanks! I slowed the character down and it fixed the problem, now it works correctly.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms