#OnCollisionEnter doesnt work (solved)
1 messages · Page 1 of 1 (latest)
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;
}
Collisions are not reported right (or at all) without a physics-based movement. Switch to the physics engine, or make your own collision detector
Mhm okay
I will have to try creating my own collision detector
Thanks for the quick answer
Could make a Cast/Overlap query instead of waiting for a collision event.
True didnt thought about this
I tried a Sphere/Cube cast but it didnt work
Overlap could work
Works perfectly fine thank you for your help
For anyone that has the same problem: https://docs.unity3d.com/ScriptReference/Physics.OverlapBox.html