memory problem

Hello, I don’t know which functions needs more memory, is it ontriggerenter+ontriggerexit or ontriggerstay? I need to check if player is in collider but in first way with triggerenter+triggerexit first have to transform object with collider for example (0,-100,0) because if player is on collider and object with colider is destroyed function ontriggerexit doesn’t work. So first solution is more complicated because there are a lot of colliders but in my opinion ontriggerstay need a lot of memory and me worried about any lags. What is your opition? Should I use triggerenter+tiggerexit or triggerstay?

None of these methods in and of themselves should use that much memory. Most games are not memory constrained anyway (though memory access is slow these days for hot code).

The biggest constraint will be processing speed. OnTriggerStay will chew through CPU cycles. In general its better to use Enter+Exit. You can use a generic list to store items inside the trigger and iterate across them every frame if needed.

in general I want to do aoe spells so my idea is to do some objects with colliders (spells) then in player’s scripts check if player is in this collider or not. There are many spells (~100) so this way have to check 100 colliders in every frame? do you think that should i do it with ontriggerenter/exit or not?

Collider checking is relatively optimised by PhysX. The system doesn’t check every collider every frame, but uses some very clever partitioning techniques to eliminate collisions that can’t possibly happen.

So I will try to use ontriggerenter/exit, thanks man!