#OnCollisionEnter doesnt work (solved)

1 messages · Page 1 of 1 (latest)

fallen radish
#

So my problem is that I am setting the position of an object via script

#

Its not physics based or anything

#

I still wanna check if its colliding with something

#

I tried:

#
public void OnCollisionEnter(Collision other)
{
   LayerMask layer = other.gameObject.layer;
   if (layer != LayerMask.NameToLayer("Buildings")) return;

   doesCollide = true;
}
distant heron
#

Collisions are not reported right (or at all) without a physics-based movement. Switch to the physics engine, or make your own collision detector

fallen radish
#

Mhm okay

#

I will have to try creating my own collision detector

#

Thanks for the quick answer

sudden parrot
#

Could make a Cast/Overlap query instead of waiting for a collision event.

fallen radish
#

True didnt thought about this

#

I tried a Sphere/Cube cast but it didnt work

#

Overlap could work

fallen radish